Skip to content

Commit 7c8c0c6

Browse files
authored
Merge pull request #23 from 0xDEC0DE/issue/20
Make the Redis broker clean up aborted jobs
2 parents 35d3928 + ace8026 commit 7c8c0c6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

spinach/job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def advance_job_status(namespace: str, job: Job, duration: float,
189189
return
190190

191191
if isinstance(err, AbortException):
192-
job.max_retries = 0
192+
job.retries = job.max_retries
193193
logger.error(
194194
'Fatal error during execution of %s after %s, canceling retries',
195195
job, duration, exc_info=err

tests/test_job.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,13 @@ def test_advance_job_status(job):
118118
RetryException('Must retry', at=now))
119119
assert job.status is JobStatus.FAILED
120120

121+
# The job should have retried twice due to previous tests, ensure that
122+
# an AbortException tops off the retry counter
121123
job.status = JobStatus.RUNNING
122124
job.max_retries = 10
125+
assert job.retries == 2
123126
advance_job_status('namespace', job, 1.0, AbortException('kaboom'))
124-
assert job.max_retries == 0
127+
assert job.retries == 10
125128
assert job.status is JobStatus.FAILED
126129

127130

0 commit comments

Comments
 (0)