Skip to content

Commit

Permalink
queue_job: job_record_with_same_identity_key ignore STARTED
Browse files Browse the repository at this point in the history
Good explanation from Guewen:

Depending on the use case, we should or should not include.
As part of my current work, I use Sidekiq daily.
They have a similar feature, but you can set a per-job parameter unique_until with options:
start (that would mean up to ENQUEUED here) or success (that would be up to STARTED here).

Think about this use case: a job refreshes a cache. Data have changed, we create a pending job. Data change again, no new job because the job is still pending.
Job starts. Data change while the job is running. In this very case, we'd like to enqueue a new job otherwise the cache will be outdated.

I reckon that both cases are valid, but I fear adding this state in the domain may, silently and in subtle ways, existing behaviors.
  • Loading branch information
simahawk committed Nov 21, 2023
1 parent c23dab1 commit bfb631c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion queue_job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def job_record_with_same_identity_key(self):
.search(
[
("identity_key", "=", self.identity_key),
("state", "in", [WAIT_DEPENDENCIES, PENDING, ENQUEUED, STARTED]),
("state", "in", [WAIT_DEPENDENCIES, PENDING, ENQUEUED]),
],
limit=1,
)
Expand Down

0 comments on commit bfb631c

Please sign in to comment.