queue
queue copied to clipboard
[17.0][Question] How to pass a job’s result to a dependent chained job?
I saw in the documentation that it’s possible to use chains and groups to build a graph of job execution. However, one question came to my mind: if Job 2 depends on the result of Job 1, how can I chain them and pass Job 1’s result into Job 2?
Is there currently a method or pattern supported by the framework to achieve this?
Please try this and write if it worked.
class MyExampleClass(models.Model):
def create_jobs(self):
job2 = (
self
.delayable()
)
job1 = (
self
.delayable()
.my_method_1()
.on_done(job2)
)
job2 = (
job2
.my_method_2(job1._build_job().uuid)
)
job1.delay()
def my_method_1(self):
return "Hello"
def my_method_2(self, job_uuid: str):
queue_job = self.env["queue.job"].browse([("uuid", "=", job_uuid)])
queue_job_results = queue_job.result
return f"{queue_job_results}, World!"