From 31a2edd0c657aabe1d7370ef1c7445bed0c3b5c4 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 26 Feb 2025 13:39:00 -0400 Subject: [PATCH] job cleanup fix --- src/dexorder/transactions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dexorder/transactions.py b/src/dexorder/transactions.py index 5ad41fc..4b6a738 100644 --- a/src/dexorder/transactions.py +++ b/src/dexorder/transactions.py @@ -172,20 +172,26 @@ async def handle_transaction_receipts(): log.warning(f'ignoring transaction request with bad type "{job.request.type}"') else: await handler.complete_transaction(job, receipt) + end_job(job) try: await handler.release_account(accounts_in_flight.pop(job.tx_id)) except KeyError: pass - end_job(job) def end_job(job): ended_jobs.append(job) -def cleanup_jobs(): +async def cleanup_jobs(): for job in ended_jobs: 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)) db.session.delete(job) ended_jobs.clear()