job cleanup fix
This commit is contained in:
@@ -172,20 +172,26 @@ async def handle_transaction_receipts():
|
|||||||
log.warning(f'ignoring transaction request with bad type "{job.request.type}"')
|
log.warning(f'ignoring transaction request with bad type "{job.request.type}"')
|
||||||
else:
|
else:
|
||||||
await handler.complete_transaction(job, receipt)
|
await handler.complete_transaction(job, receipt)
|
||||||
|
end_job(job)
|
||||||
try:
|
try:
|
||||||
await handler.release_account(accounts_in_flight.pop(job.tx_id))
|
await handler.release_account(accounts_in_flight.pop(job.tx_id))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
end_job(job)
|
|
||||||
|
|
||||||
|
|
||||||
def end_job(job):
|
def end_job(job):
|
||||||
ended_jobs.append(job)
|
ended_jobs.append(job)
|
||||||
|
|
||||||
|
|
||||||
def cleanup_jobs():
|
async def cleanup_jobs():
|
||||||
for job in ended_jobs:
|
for job in ended_jobs:
|
||||||
log.debug(f'ending job {job.id}')
|
log.debug(f'ending job {job.id}')
|
||||||
|
if job.tx_id in accounts_in_flight:
|
||||||
|
try:
|
||||||
|
handler = TransactionHandler.of(job.request.type)
|
||||||
|
await handler.release_account(accounts_in_flight.pop(job.tx_id))
|
||||||
|
except KeyError:
|
||||||
|
log.warning(f'ignoring transaction request with bad type "{job.request.type}"')
|
||||||
in_flight.discard((job.request.type, job.request.key))
|
in_flight.discard((job.request.type, job.request.key))
|
||||||
db.session.delete(job)
|
db.session.delete(job)
|
||||||
ended_jobs.clear()
|
ended_jobs.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user