1+ .. image :: https://odoo-community.org/readme-banner-image
2+ :target: https://odoo-community.org/get-involved?utm_source=readme
3+ :alt: Odoo Community Association
4+
15=========
26Job Queue
37=========
@@ -7,13 +11,13 @@ Job Queue
711 !! This file is generated by oca-gen-addon-readme !!
812 !! changes will be overwritten. !!
913 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10- !! source digest: sha256:1d40b76459c2a2bb768659c26ae8e531e52abf618a6f3febc027c0cf12a29bf1
14+ !! source digest: sha256:034783f35505ccb34f61a02d57eb1b991de4319a83220325e4a9426d653b5329
1115 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1216
1317.. |badge1 | image :: https://img.shields.io/badge/maturity-Mature-brightgreen.png
1418 :target: https://odoo-community.org/page/development-status
1519 :alt: Mature
16- .. |badge2 | image :: https://img.shields.io/badge/licence -LGPL--3-blue.png
20+ .. |badge2 | image :: https://img.shields.io/badge/license -LGPL--3-blue.png
1721 :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1822 :alt: License: LGPL-3
1923.. |badge3 | image :: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github
@@ -61,20 +65,20 @@ instantaneous if no other job is running.
6165
6266Features:
6367
64- - Views for jobs, jobs are stored in PostgreSQL
65- - Jobrunner: execute the jobs, highly efficient thanks to PostgreSQL's
66- NOTIFY
67- - Channels: give a capacity for the root channel and its sub-channels
68- and segregate jobs in them. Allow for instance to restrict heavy jobs
69- to be executed one at a time while little ones are executed 4 at a
70- times.
71- - Retries: Ability to retry jobs by raising a type of exception
72- - Retry Pattern: the 3 first tries, retry after 10 seconds, the 5 next
73- tries, retry after 1 minutes, ...
74- - Job properties: priorities, estimated time of arrival (ETA), custom
75- description, number of retries
76- - Related Actions: link an action on the job view, such as open the
77- record concerned by the job
68+ - Views for jobs, jobs are stored in PostgreSQL
69+ - Jobrunner: execute the jobs, highly efficient thanks to PostgreSQL's
70+ NOTIFY
71+ - Channels: give a capacity for the root channel and its sub-channels
72+ and segregate jobs in them. Allow for instance to restrict heavy jobs
73+ to be executed one at a time while little ones are executed 4 at a
74+ times.
75+ - Retries: Ability to retry jobs by raising a type of exception
76+ - Retry Pattern: the 3 first tries, retry after 10 seconds, the 5 next
77+ tries, retry after 1 minutes, ...
78+ - Job properties: priorities, estimated time of arrival (ETA), custom
79+ description, number of retries
80+ - Related Actions: link an action on the job view, such as open the
81+ record concerned by the job
7882
7983**Table of contents **
8084
@@ -89,18 +93,18 @@ Be sure to have the ``requests`` library.
8993Configuration
9094=============
9195
92- - Using environment variables and command line:
96+ - Using environment variables and command line:
9397
94- - Adjust environment variables (optional):
98+ - Adjust environment variables (optional):
9599
96- - ``ODOO_QUEUE_JOB_CHANNELS=root:4 `` or any other channels
97- configuration. The default is ``root:1 ``
98- - if ``xmlrpc_port `` is not set: ``ODOO_QUEUE_JOB_PORT=8069 ``
100+ - ``ODOO_QUEUE_JOB_CHANNELS=root:4 `` or any other channels
101+ configuration. The default is ``root:1 ``
102+ - if ``xmlrpc_port `` is not set: ``ODOO_QUEUE_JOB_PORT=8069 ``
99103
100- - Start Odoo with ``--load=web,queue_job `` and ``--workers `` greater
101- than 1. [1 ]_
104+ - Start Odoo with ``--load=web,queue_job `` and ``--workers `` greater
105+ than 1. [1 ]_
102106
103- - Using the Odoo configuration file:
107+ - Using the Odoo configuration file:
104108
105109.. code :: ini
106110
@@ -113,8 +117,8 @@ Configuration
113117 [queue_job]
114118 channels = root:2
115119
116- - Confirm the runner is starting correctly by checking the odoo log
117- file:
120+ - Confirm the runner is starting correctly by checking the odoo log
121+ file:
118122
119123::
120124
@@ -123,14 +127,14 @@ Configuration
123127 ...INFO...queue_job.jobrunner.runner: queue job runner ready for db <dbname>
124128 ...INFO...queue_job.jobrunner.runner: database connections ready
125129
126- - Create jobs (eg using ``base_import_async ``) and observe they start
127- immediately and in parallel.
128- - Tip: to enable debug logging for the queue job, use
129- ``--log-handler=odoo.addons.queue_job:DEBUG ``
130+ - Create jobs (eg using ``base_import_async ``) and observe they start
131+ immediately and in parallel.
132+ - Tip: to enable debug logging for the queue job, use
133+ ``--log-handler=odoo.addons.queue_job:DEBUG ``
130134
131- - Jobs that remain in ``enqueued `` or ``started `` state (because, for
132- instance, their worker has been killed) will be automatically
133- re-queued.
135+ - Jobs that remain in ``enqueued `` or ``started `` state (because, for
136+ instance, their worker has been killed) will be automatically
137+ re-queued.
134138
135139.. [1 ]
136140 It works with the threaded Odoo server too, although this way of
@@ -287,20 +291,20 @@ only start when the previous one is done:
287291 Enqueing Job Options
288292~~~~~~~~~~~~~~~~~~~~
289293
290- - priority: default is 10, the closest it is to 0, the faster it will
291- be executed
292- - eta: Estimated Time of Arrival of the job. It will not be executed
293- before this date/time
294- - max_retries: default is 5, maximum number of retries before giving up
295- and set the job state to 'failed'. A value of 0 means infinite
296- retries.
297- - description: human description of the job. If not set, description is
298- computed from the function doc or method name
299- - channel: the complete name of the channel to use to process the
300- function. If specified it overrides the one defined on the function
301- - identity_key: key uniquely identifying the job, if specified and a
302- job with the same key has not yet been run, the new job will not be
303- created
294+ - priority: default is 10, the closest it is to 0, the faster it will be
295+ executed
296+ - eta: Estimated Time of Arrival of the job. It will not be executed
297+ before this date/time
298+ - max_retries: default is 5, maximum number of retries before giving up
299+ and set the job state to 'failed'. A value of 0 means infinite
300+ retries.
301+ - description: human description of the job. If not set, description is
302+ computed from the function doc or method name
303+ - channel: the complete name of the channel to use to process the
304+ function. If specified it overrides the one defined on the function
305+ - identity_key: key uniquely identifying the job, if specified and a job
306+ with the same key has not yet been run, the new job will not be
307+ created
304308
305309Configure default options for jobs
306310~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -371,11 +375,11 @@ dictionary on the job function:
371375 " kwargs" : {" name" : " Partner" },
372376 }
373377
374- - ``enable ``: when ``False ``, the button has no effect (default:
375- ``True ``)
376- - ``func_name ``: name of the method on ``queue.job `` that returns an
377- action
378- - ``kwargs ``: extra arguments to pass to the related action method
378+ - ``enable ``: when ``False ``, the button has no effect (default:
379+ ``True ``)
380+ - ``func_name ``: name of the method on ``queue.job `` that returns an
381+ action
382+ - ``kwargs ``: extra arguments to pass to the related action method
379383
380384Example of related action code:
381385
@@ -419,10 +423,10 @@ integers:
419423
420424 Based on this configuration, we can tell that:
421425
422- - 5 first retries are postponed 10 seconds later
423- - retries 5 to 10 postponed 20 seconds later
424- - retries 10 to 15 postponed 30 seconds later
425- - all subsequent retries postponed 5 minutes later
426+ - 5 first retries are postponed 10 seconds later
427+ - retries 5 to 10 postponed 20 seconds later
428+ - retries 10 to 15 postponed 30 seconds later
429+ - all subsequent retries postponed 5 minutes later
426430
427431**Job Context **
428432
@@ -469,11 +473,11 @@ Testing
469473The recommended way to test jobs, rather than running them directly and
470474synchronously is to split the tests in two parts:
471475
472- - one test where the job is mocked (trap jobs with ``trap_jobs() ``
473- and the test only verifies that the job has been delayed with the
474- expected arguments
475- - one test that only calls the method of the job synchronously, to
476- validate the proper behavior of this method only
476+ - one test where the job is mocked (trap jobs with ``trap_jobs() ``
477+ and the test only verifies that the job has been delayed with the
478+ expected arguments
479+ - one test that only calls the method of the job synchronously, to
480+ validate the proper behavior of this method only
477481
478482Proceeding this way means that you can prove that jobs will be enqueued
479483properly at runtime, and it ensures your code does not have a different
@@ -597,14 +601,14 @@ synchronously
597601Tips and tricks
598602~~~~~~~~~~~~~~~
599603
600- - ** Idempotency**
601- (https:// www.restapitutorial.com/ lessons/ idempotency.html): The
602- queue_job should be idempotent so they can be retried several times
603- without impact on the data.
604- - ** The job should test at the very beginning its relevance** : the
605- moment the job will be executed is unknown by design. So the first
606- task of a job should be to check if the related work is still
607- relevant at the moment of the execution.
604+ - ** Idempotency**
605+ (https:// www.restapitutorial.com/ lessons/ idempotency.html): The
606+ queue_job should be idempotent so they can be retried several times
607+ without impact on the data.
608+ - ** The job should test at the very beginning its relevance** : the
609+ moment the job will be executed is unknown by design. So the first
610+ task of a job should be to check if the related work is still relevant
611+ at the moment of the execution.
608612
609613Patterns
610614~~~~~~~~
@@ -621,20 +625,19 @@ Through the time, two main patterns emerged:
621625Known issues / Roadmap
622626======================
623627
624- - After creating a new database or installing `` queue_job`` on an
625- existing database, Odoo must be restarted for the runner to detect
626- it.
627- - When Odoo shuts down normally, it waits for running jobs to finish.
628- However, when the Odoo server crashes or is otherwise force- stopped,
629- running jobs are interrupted while the runner has no chance to know
630- they have been aborted. In such situations, jobs may remain in
631- `` started`` or `` enqueued`` state after the Odoo server is halted.
632- Since the runner has no way to know if they are actually running or
633- not , and does not know for sure if it is safe to restart the jobs, it
634- does not attempt to restart them automatically. Such stale jobs
635- therefore fill the running queue and prevent other jobs to start. You
636- must therefore requeue them manually, either from the Jobs view, or
637- by running the following SQL statement * before starting Odoo* :
628+ - After creating a new database or installing `` queue_job`` on an
629+ existing database, Odoo must be restarted for the runner to detect it.
630+ - When Odoo shuts down normally, it waits for running jobs to finish.
631+ However, when the Odoo server crashes or is otherwise force- stopped,
632+ running jobs are interrupted while the runner has no chance to know
633+ they have been aborted. In such situations, jobs may remain in
634+ `` started`` or `` enqueued`` state after the Odoo server is halted.
635+ Since the runner has no way to know if they are actually running or
636+ not , and does not know for sure if it is safe to restart the jobs, it
637+ does not attempt to restart them automatically. Such stale jobs
638+ therefore fill the running queue and prevent other jobs to start. You
639+ must therefore requeue them manually, either from the Jobs view, or by
640+ running the following SQL statement * before starting Odoo* :
638641
639642.. code:: sql
640643
@@ -646,11 +649,11 @@ Changelog
646649Next
647650----
648651
649- - [ADD ] Run jobrunner as a worker process instead of a thread in the
650- main process (when running with -- workers > 0 )
651- - [REF ] `` @ job`` and `` @ related_action`` deprecated, any method can be
652- delayed, and configured using `` queue.job.function`` records
653- - [MIGRATION ] from 13.0 branched at rev. e24ff4b
652+ - [ADD ] Run jobrunner as a worker process instead of a thread in the
653+ main process (when running with -- workers > 0 )
654+ - [REF ] `` @ job`` and `` @ related_action`` deprecated, any method can be
655+ delayed, and configured using `` queue.job.function`` records
656+ - [MIGRATION ] from 13.0 branched at rev. e24ff4b
654657
655658Bug Tracker
656659========== =
@@ -674,21 +677,21 @@ Authors
674677Contributors
675678------------
676679
677- - Guewen Baconnier < guewen.baconnier@ camptocamp.com>
678- - Stéphane Bidoul < stephane.bidoul@ acsone.eu>
679- - Matthieu Dietrich < matthieu.dietrich@ camptocamp.com>
680- - Jos De Graeve < Jos.DeGraeve@ apertoso.be>
681- - David Lefever < dl@ taktik.be>
682- - Laurent Mignon < laurent.mignon@ acsone.eu>
683- - Laetitia Gangloff < laetitia.gangloff@ acsone.eu>
684- - Cédric Pigeon < cedric.pigeon@ acsone.eu>
685- - Tatiana Deribina < tatiana.deribina@ avoin.systems>
686- - Souheil Bejaoui < souheil.bejaoui@ acsone.eu>
687- - Eric Antones < eantones@ nuobit.com>
688- - Simone Orsi < simone.orsi@ camptocamp.com>
689- - Nguyen Minh Chien < chien@ trobz.com>
690- - Tran Quoc Duong < duongtq@ trobz.com>
691- - Vo Hong Thien < thienvh@ trobz.com>
680+ - Guewen Baconnier < guewen.baconnier@ camptocamp.com>
681+ - Stéphane Bidoul < stephane.bidoul@ acsone.eu>
682+ - Matthieu Dietrich < matthieu.dietrich@ camptocamp.com>
683+ - Jos De Graeve < Jos.DeGraeve@ apertoso.be>
684+ - David Lefever < dl@ taktik.be>
685+ - Laurent Mignon < laurent.mignon@ acsone.eu>
686+ - Laetitia Gangloff < laetitia.gangloff@ acsone.eu>
687+ - Cédric Pigeon < cedric.pigeon@ acsone.eu>
688+ - Tatiana Deribina < tatiana.deribina@ avoin.systems>
689+ - Souheil Bejaoui < souheil.bejaoui@ acsone.eu>
690+ - Eric Antones < eantones@ nuobit.com>
691+ - Simone Orsi < simone.orsi@ camptocamp.com>
692+ - Nguyen Minh Chien < chien@ trobz.com>
693+ - Tran Quoc Duong < duongtq@ trobz.com>
694+ - Vo Hong Thien < thienvh@ trobz.com>
692695
693696Other credits
694697------------ -
0 commit comments