mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 23:02:19 +00:00
Added timeout options for Python 2.6 and above
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import urllib, urllib2
|
||||
from hashlib import sha1
|
||||
from datetime import datetime, timedelta
|
||||
@@ -65,7 +66,10 @@ class CachedDocumentManager(models.Manager):
|
||||
req = urllib2.Request(url)
|
||||
req.add_header('CCP-Contact', 'matalok@pleaseignore.com')
|
||||
try:
|
||||
if sys.version_info < (2, 6):
|
||||
conn = urllib2.urlopen(req)
|
||||
else:
|
||||
conn = urllib2.urlopen(req, timeout=5)
|
||||
except urllib2.HTTPError, e:
|
||||
print "HTTP Error Code: %s" % e.code
|
||||
raise DocumentRetrievalError(e.code)
|
||||
|
||||
Reference in New Issue
Block a user