mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Add retry to API import errors, and catch DocumentRetreivalErrors
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user