I have this piece of code
for rec in new_records:
job1 = rec.delayable().action_exchange_generate()
if not skip_send:
# Chain send job
job1.on_done(rec.delayable().action_exchange_send())
job1.delay()
I inject identity_key=identity_exact here.
Here I test that no duplicated job gets created but it does not work.
def test_job(self):
with trap_jobs() as trap:
self.backend._check_output_exchange_sync(record_ids=self.record.ids)
trap.assert_jobs_count(2)
trap.assert_enqueued_job(
self.backend.exchange_record_model.action_exchange_generate,
)
trap.assert_enqueued_job(
self.backend.exchange_record_model.action_exchange_send,
)
self.backend._check_output_exchange_sync(record_ids=self.record.ids)
self.backend._check_output_exchange_sync(record_ids=self.record.ids)
# identity key should prevent having new jobs
trap.assert_jobs_count(2)
I have 6 jobs at the end while I expect to have still 2 jobs only.
I've inspected the identity keys of those jobs and they all match 🤔
I also checked if job.job_record_with_same_identity_key gets called: it is called but it cannot find the jobs.
Flushing does not help.
I've created a silly server action to test the same piece of code via UI on the same record and gives me the same result...
Am I doing something wrong or we have a bug w/ chained jobs?
Side note: unless I'm mistaken I think job.job_record_with_same_identity_key does not search for all possible states when you have a job that is waiting for a dependency here
|
("state", "in", [PENDING, ENQUEUED]), |
I have this piece of code
I inject
identity_key=identity_exacthere.Here I test that no duplicated job gets created but it does not work.
I have 6 jobs at the end while I expect to have still 2 jobs only.
I've inspected the identity keys of those jobs and they all match 🤔
I also checked if
job.job_record_with_same_identity_keygets called: it is called but it cannot find the jobs.Flushing does not help.
I've created a silly server action to test the same piece of code via UI on the same record and gives me the same result...
Am I doing something wrong or we have a bug w/ chained jobs?
Side note: unless I'm mistaken I think
job.job_record_with_same_identity_keydoes not search for all possible states when you have a job that is waiting for a dependency herequeue/queue_job/job.py
Line 303 in 199e9e4