delay re-running query after database locked error

This commit is contained in:
Jack Robison 2018-02-27 17:20:33 -05:00
parent 476a44ddb5
commit bceaaa5724
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -78,7 +78,8 @@ def rerun_if_locked(f):
log.warning("database was locked. rerunning %s with args %s, kwargs %s", log.warning("database was locked. rerunning %s with args %s, kwargs %s",
str(f), str(args), str(kwargs)) str(f), str(args), str(kwargs))
if rerun_count < max_attempts: if rerun_count < max_attempts:
return task.deferLater(reactor, 0, inner_wrapper, rerun_count + 1, *args, **kwargs) delay = 2**rerun_count
return task.deferLater(reactor, delay, inner_wrapper, rerun_count + 1, *args, **kwargs)
raise err raise err
def inner_wrapper(rerun_count, *args, **kwargs): def inner_wrapper(rerun_count, *args, **kwargs):