Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a 10-second timeout to all HTTP(S) requests #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pyepsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def as_esri_wkt(self):
"""
url = '{prefix}{code}.esriwkt?download'.format(prefix=EPSG_IO_URL,
code=self.id)
return requests.get(url).text
return requests.get(url, timeout=10).text

@functools.lru_cache(maxsize=None)
def as_html(self):
Expand All @@ -150,7 +150,7 @@ def as_html(self):
"""
url = '{prefix}{code}.html?download'.format(prefix=EPSG_IO_URL,
code=self.id)
return requests.get(url).text
return requests.get(url, timeout=10).text

@functools.lru_cache(maxsize=None)
def as_proj4(self):
Expand All @@ -167,7 +167,7 @@ def as_proj4(self):
"""
url = '{prefix}{code}.proj4?download'.format(prefix=EPSG_IO_URL,
code=self.id)
return requests.get(url).text.strip()
return requests.get(url, timeout=10).text.strip()

@functools.lru_cache(maxsize=None)
def as_wkt(self):
Expand All @@ -182,7 +182,7 @@ def as_wkt(self):
"""
url = '{prefix}{code}.wkt?download'.format(prefix=EPSG_IO_URL,
code=self.id)
return requests.get(url).text
return requests.get(url, timeout=10).text

@functools.lru_cache(maxsize=None)
def domain_of_validity(self):
Expand All @@ -203,7 +203,7 @@ def domain_of_validity(self):
domain_href = domain.attrib[XLINK_NS + 'href']
url = '{prefix}{code}.gml?download'.format(prefix=EPSG_IO_URL,
code=domain_href)
xml = requests.get(url).content
xml = requests.get(url, timeout=10).content
gml = ET.fromstring(xml)

def extract_bound(tag):
Expand Down Expand Up @@ -284,7 +284,7 @@ def get(code):
"""
url = '{prefix}{code}.gml?download'.format(prefix=EPSG_IO_URL,
code=code)
xml = requests.get(url).content
xml = requests.get(url, timeout=10).content
root = ET.fromstring(xml)
class_for_tag = {
GML_NS + 'CartesianCS': CartesianCS,
Expand Down