Add retry to API import errors, and catch DocumentRetreivalErrors

This commit is contained in:
2011-08-25 10:28:53 +01:00
parent 741738b18d
commit 2021da2c92

View File

@@ -40,18 +40,20 @@ def queue_apikey_updates(update_delay=86400, batch_size=50):
@task(ignore_result=True)
def import_apikey(api_userid, api_key, user=None, force_cache=False):
def import_apikey(api_userid, api_key, user=None, force_cache=False, **kwargs):
"""
Imports a EVE Account from the API, doesn't return a result
"""
log = import_apikey.get_logger()
try:
import_apikey_func(api_userid, api_key, user, force_cache, log)
except:
log.error('Error importing API Key')
except (APIAccessException, DocumentRetrievalError), exc:
log.error('Error importing API Key - flagging for retry')
import_apikey.retry(args=[api_userid, api_key, user, force_cache], exc=exc, kwargs=kwargs)
@task()
def import_apikey_result(api_userid, api_key, user=None, force_cache=False, callback=None):
def import_apikey_result(api_userid, api_key, user=None, force_cache=False, callback=None, **kwargs):
"""
Imports a EVE Account from the API and returns the account object when completed
"""
@@ -59,8 +61,9 @@ def import_apikey_result(api_userid, api_key, user=None, force_cache=False, call
log = import_apikey_result.get_logger()
try:
results = import_apikey_func(api_userid, api_key, user, force_cache, log)
except APIAccessException, exc:
except (APIAccessException, DocumentRetrievalError), exc:
log.error('Error importing API Key - flagging for retry')
import_apikey_result.retry(args=[api_userid, api_key, user, force_cache, callback], exc=exc, kwargs=kwargs)
else:
if callback:
subtask(callback).delay(account=results)