mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +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)
|
@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
|
Imports a EVE Account from the API, doesn't return a result
|
||||||
"""
|
"""
|
||||||
log = import_apikey.get_logger()
|
log = import_apikey.get_logger()
|
||||||
try:
|
try:
|
||||||
import_apikey_func(api_userid, api_key, user, force_cache, log)
|
import_apikey_func(api_userid, api_key, user, force_cache, log)
|
||||||
except:
|
except (APIAccessException, DocumentRetrievalError), exc:
|
||||||
log.error('Error importing API Key')
|
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()
|
@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
|
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()
|
log = import_apikey_result.get_logger()
|
||||||
try:
|
try:
|
||||||
results = import_apikey_func(api_userid, api_key, user, force_cache, log)
|
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')
|
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:
|
else:
|
||||||
if callback:
|
if callback:
|
||||||
subtask(callback).delay(account=results)
|
subtask(callback).delay(account=results)
|
||||||
|
|||||||
Reference in New Issue
Block a user