Commit b3423443 authored by tarek's avatar tarek

Introduced a socket timeout of 15 seconds on url openings fixes #48

--HG--
branch : distribute
extra : rebase_source : d4e3831771aa049e71d64f22e315352fa8906dd1
parent a229fc69
......@@ -7,7 +7,7 @@ CHANGES
------
* Found another case of SandboxViolation - fixed
* Issue 48: Introduced a socket timeout of 15 seconds on url openings
------
0.6.10
......
......@@ -25,6 +25,8 @@ __all__ = [
'interpret_distro_name',
]
_SOCKET_TIMEOUT = 15
def parse_bdist_wininst(name):
"""Return (base,pyversion) or (None,None) for possible .exe name"""
......@@ -717,6 +719,17 @@ def htmldecode(text):
def socket_timeout(timeout=15):
def _socket_timeout(func):
def _socket_timeout(*args, **kwargs):
old_timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(timeout)
try:
return func(*args, **kwargs)
finally:
socket.setdefaulttimeout(old_timeout)
return _socket_timeout
return _socket_timeout
def open_with_auth(url):
......@@ -749,6 +762,8 @@ def open_with_auth(url):
return fp
# adding a timeout to avoid freezing package_index
open_with_auth = socket_timeout(_SOCKET_TIMEOUT)(open_with_auth)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment