mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-17 11:49:29 +00:00
Allow for the call to define the timeout, set at a default of 30secs
This commit is contained in:
@@ -131,7 +131,7 @@ class OpTimerHandler(BaseHandler):
|
||||
error_doc = {'ops': [{'startsIn': -1, 'eventID': 0, 'ownerName': '', 'eventDate': '', 'eventTitle': '<div style="text-align:center">The EVE API calendar is unavailable</div>', 'duration': 0, 'isImportant': 0, 'eventText': 'Fuck CCP tbqh imho srsly', 'endsIn':-1, 'forumLink': ''}]}
|
||||
|
||||
try:
|
||||
cached_doc = CachedDocument.objects.api_query('/char/UpcomingCalendarEvents.xml.aspx', params, service="Optimer")
|
||||
cached_doc = CachedDocument.objects.api_query('/char/UpcomingCalendarEvents.xml.aspx', params, timeout=10, service="Optimer")
|
||||
except DocumentRetrievalError:
|
||||
return error_doc
|
||||
dom = minidom.parseString(cached_doc.body.encode('utf-8'))
|
||||
|
||||
@@ -39,7 +39,7 @@ class CachedDocumentManager(models.Manager):
|
||||
|
||||
return url
|
||||
|
||||
def api_query(self, url_path, params={}, no_cache=False, exceptions=True, service="Auth"):
|
||||
def api_query(self, url_path, params={}, no_cache=False, exceptions=True, timeout=30, service="Auth"):
|
||||
"""
|
||||
Transparently handles querying EVE API or retrieving the document from
|
||||
the cache.
|
||||
@@ -69,7 +69,7 @@ class CachedDocumentManager(models.Manager):
|
||||
if sys.version_info < (2, 6):
|
||||
conn = urllib2.urlopen(req)
|
||||
else:
|
||||
conn = urllib2.urlopen(req, timeout=5)
|
||||
conn = urllib2.urlopen(req, timeout=timeout)
|
||||
except urllib2.HTTPError, e:
|
||||
print "HTTP Error Code: %s" % e.code
|
||||
raise DocumentRetrievalError(e.code)
|
||||
|
||||
Reference in New Issue
Block a user