From 40f738df42ee181ae2df215384551ad4963953b5 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Thu, 21 Dec 2023 13:41:47 +0100 Subject: [PATCH 1/3] [IMP] queue_job_cron: Avoid parallel run By default, odoo never runs the same cron job in parallel. This commit uses the identity key mechanism to enforce this mechanism when a cron job is run as a queue job. This behaviour can be controlled by a new setting on the cron definition but is activated by default to keep the original behaviour --- queue_job_cron/views/ir_cron_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queue_job_cron/views/ir_cron_view.xml b/queue_job_cron/views/ir_cron_view.xml index 0a9a64d275..135b71402a 100644 --- a/queue_job_cron/views/ir_cron_view.xml +++ b/queue_job_cron/views/ir_cron_view.xml @@ -9,7 +9,7 @@ Date: Tue, 19 Nov 2024 09:21:11 +0100 Subject: [PATCH 2/3] [IMP] queue_job: Add split method --- queue_job/delay.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/queue_job/delay.py b/queue_job/delay.py index 251e4f7a84..0ba54e48a9 100644 --- a/queue_job/delay.py +++ b/queue_job/delay.py @@ -232,7 +232,7 @@ def _ensure_same_graph_uuid(jobs): elif jobs_count == 1: if jobs[0].graph_uuid: raise ValueError( - f"Job {jobs[0]} is a single job, it should not" " have a graph uuid" + f"Job {jobs[0]} is a single job, it should not have a graph uuid" ) else: graph_uuids = {job.graph_uuid for job in jobs if job.graph_uuid} @@ -483,11 +483,10 @@ def _tail(self): return [self] def __repr__(self): - return "Delayable({}.{}({}, {}))".format( - self.recordset, - self._job_method.__name__ if self._job_method else "", - self._job_args, - self._job_kwargs, + return ( + f"Delayable({self.recordset}." + f"{self._job_method.__name__ if self._job_method else ''}" + f"({self._job_args}, {self._job_kwargs}))" ) def __del__(self): @@ -656,9 +655,9 @@ def _delay_delayable(*args, **kwargs): return _delay_delayable def __str__(self): - return "DelayableRecordset({}{})".format( - self.delayable.recordset._name, - getattr(self.delayable.recordset, "_ids", ""), + return ( + f"DelayableRecordset({self.delayable.recordset._name}" + f"{getattr(self.delayable.recordset, '_ids', '')})" ) __repr__ = __str__ From 76264344e04e100cb9ca92437689bb585d7eaf61 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 16 Sep 2024 13:43:47 +0200 Subject: [PATCH 3/3] [FIX] queue_job: typo --- queue_job/README.rst | 2 +- queue_job/readme/USAGE.md | 2 +- queue_job/static/description/index.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/queue_job/README.rst b/queue_job/README.rst index 8fe8ec405c..80713f43ca 100644 --- a/queue_job/README.rst +++ b/queue_job/README.rst @@ -434,7 +434,7 @@ running Odoo** When you are developing (ie: connector modules) you might want to bypass the queue job and run your code immediately. -To do so you can set QUEUE_JOB\__NO_DELAY=1 in your enviroment. +To do so you can set QUEUE_JOB\__NO_DELAY=1 in your environment. **Bypass jobs in tests** diff --git a/queue_job/readme/USAGE.md b/queue_job/readme/USAGE.md index c08374b9fc..deb6fe2aca 100644 --- a/queue_job/readme/USAGE.md +++ b/queue_job/readme/USAGE.md @@ -290,7 +290,7 @@ running Odoo** When you are developing (ie: connector modules) you might want to bypass the queue job and run your code immediately. -To do so you can set QUEUE_JOB\_\_NO_DELAY=1 in your enviroment. +To do so you can set QUEUE_JOB\_\_NO_DELAY=1 in your environment. **Bypass jobs in tests** diff --git a/queue_job/static/description/index.html b/queue_job/static/description/index.html index 05893ddef0..82c8f32c74 100644 --- a/queue_job/static/description/index.html +++ b/queue_job/static/description/index.html @@ -755,7 +755,7 @@

Configure default options for job running Odoo

When you are developing (ie: connector modules) you might want to bypass the queue job and run your code immediately.

-

To do so you can set QUEUE_JOB__NO_DELAY=1 in your enviroment.

+

To do so you can set QUEUE_JOB__NO_DELAY=1 in your environment.

Bypass jobs in tests

When writing tests on job-related methods is always tricky to deal with delayed recordsets. To make your testing life easier you can set