Skip to content

Commit

Permalink
Merge 5e52315 into f1d2cb8
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDEC0DE committed May 10, 2024
2 parents f1d2cb8 + 5e52315 commit d2e5ec2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 7 additions & 9 deletions spinach/brokers/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,13 @@ def get_jobs_from_queue(self, queue: str, max_jobs: int) -> List[Job]:
return jobs

def remove_job_from_running(self, job: Job):
if job.max_retries > 0:
self._run_script(
self._remove_job_from_running,
self._to_namespaced(RUNNING_JOBS_KEY.format(self._id)),
self._to_namespaced(MAX_CONCURRENCY_KEY),
self._to_namespaced(CURRENT_CONCURRENCY_KEY),
job.serialize(),
)

self._run_script(
self._remove_job_from_running,
self._to_namespaced(RUNNING_JOBS_KEY.format(self._id)),
self._to_namespaced(MAX_CONCURRENCY_KEY),
self._to_namespaced(CURRENT_CONCURRENCY_KEY),
job.serialize(),
)
self._something_happened.set()

def _subscriber_func(self):
Expand Down
1 change: 1 addition & 0 deletions tests/test_redis_brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def test_running_job(broker):
)
# Try to remove it, even if it doesn't exist in running
broker.remove_job_from_running(job)
assert broker._r.hget(running_jobs_key, str(job.id)) is None

# Idempotent job - get from queue
job = Job('foo_task', 'foo_queue', datetime.now(timezone.utc), 10)
Expand Down

0 comments on commit d2e5ec2

Please sign in to comment.