fix: prevent transient errors from permanently killing cleanup loops

This commit is contained in:
DrMelone 2026-04-12 22:48:25 +02:00
parent 2ca7c3bfe6
commit daf107a993

View file

@ -186,10 +186,16 @@ async def run_with_lock(acquire_fn, renew_fn, release_fn, work_fn, interval, loc
if not renew_fn():
log.info('Lock renewal failed. Will re-acquire.')
break
await work_fn()
try:
await work_fn()
except Exception:
log.exception('Periodic work_fn failed; will retry next cycle')
await asyncio.sleep(interval)
finally:
release_fn()
try:
release_fn()
except Exception:
log.exception('Failed to release lock')
async def periodic_session_pool_cleanup():