fix: use pop() instead of del for job_tasks cleanup in run_job#521
Open
trionnis wants to merge 1 commit intopython-arq:mainfrom
Open
fix: use pop() instead of del for job_tasks cleanup in run_job#521trionnis wants to merge 1 commit intopython-arq:mainfrom
trionnis wants to merge 1 commit intopython-arq:mainfrom
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #521 +/- ##
==========================================
- Coverage 96.27% 96.11% -0.17%
==========================================
Files 11 11
Lines 1074 1081 +7
Branches 209 144 -65
==========================================
+ Hits 1034 1039 +5
- Misses 19 21 +2
Partials 21 21
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
finallyblock inWorker.run_job()usesdel self.job_tasks[job_id](line 604) which raisesKeyErrorif the entry was already removed. This crashes the entire worker process, killing all concurrent in-flight jobs.The bug
The
finallyblock always runs — even when the outerexceptcatches an exception. If thejob_idkey was already removed fromself.job_tasks(e.g. during cancellation handling), the
delraises an unhandledKeyErrorthat propagates up and kills the worker process. Withmax_jobs > 1, this takes down all concurrent tasks on that worker, not just the one that triggered the error.Traceback
Fix
Replace
del self.job_tasks[job_id]withself.job_tasks.pop(job_id, None). This is a no-op if the key is already gone, and identical behavior otherwise. Cleanup code infinallyblocks should be idempotent.