diff --git a/queue_job/README.rst b/queue_job/README.rst index 947b481b51..26614d103f 100644 --- a/queue_job/README.rst +++ b/queue_job/README.rst @@ -132,6 +132,19 @@ Configuration .. [1] It works with the threaded Odoo server too, although this way of running Odoo is obviously not for production purposes. +* Be sure to check out *Jobs Garbage Collector* CRON and change *enqueued_delta* and *started_delta* parameters to your needs. + + * ``enqueued_delta``: Spent time in minutes after which an enqueued job is considered stuck. + Set it to 0 to disable this check. + * ``started_delta``: Spent time in minutes after which a started job is considered stuck. + This parameter should not be less than ``--limit-time-real // 60`` parameter in your configuration. + Set it to 0 to disable this check. Set it to -1 to automate it, based in the server's ``--limit-time-real`` config parameter. + + .. code-block:: python + + # `model` corresponds to 'queue.job' model + model.requeue_stuck_jobs(enqueued_delta=1, started_delta=-1) + Usage ===== diff --git a/queue_job/data/queue_data.xml b/queue_job/data/queue_data.xml index ca5a747746..55bcb3f5fc 100644 --- a/queue_job/data/queue_data.xml +++ b/queue_job/data/queue_data.xml @@ -8,7 +8,9 @@ -1 code - model.requeue_stuck_jobs() + model.requeue_stuck_jobs(enqueued_delta=1, started_delta=-1) diff --git a/queue_job/models/queue_job.py b/queue_job/models/queue_job.py index 0098ffeeac..8af7468b7c 100644 --- a/queue_job/models/queue_job.py +++ b/queue_job/models/queue_job.py @@ -344,7 +344,7 @@ def button_cancelled(self): def requeue(self): jobs_to_requeue = self.filtered(lambda job_: job_.state != WAIT_DEPENDENCIES) jobs_to_requeue._change_job_state(PENDING) - return True + return jobs_to_requeue def _message_post_on_failure(self): # subscribe the users now to avoid to subscribe them @@ -417,20 +417,23 @@ def autovacuum(self): break return True - def requeue_stuck_jobs(self, enqueued_delta=5, started_delta=0): + def requeue_stuck_jobs(self, enqueued_delta=1, started_delta=0): """Fix jobs that are in a bad states :param in_queue_delta: lookup time in minutes for jobs - that are in enqueued state + that are in enqueued state, + 0 means that it is not checked :param started_delta: lookup time in minutes for jobs - that are in enqueued state, - 0 means that it is not checked + that are in started state, + 0 means that it is not checked, + -1 will use `--limit-time-real` config value """ - self._get_stuck_jobs_to_requeue( + if started_delta == -1: + started_delta = (config["limit_time_real"] // 60) + 1 + return self._get_stuck_jobs_to_requeue( enqueued_delta=enqueued_delta, started_delta=started_delta ).requeue() - return True def _get_stuck_jobs_domain(self, queue_dl, started_dl): domain = [] diff --git a/queue_job/readme/CONFIGURE.rst b/queue_job/readme/CONFIGURE.rst index d5782be57d..b9547b9465 100644 --- a/queue_job/readme/CONFIGURE.rst +++ b/queue_job/readme/CONFIGURE.rst @@ -41,3 +41,16 @@ .. [1] It works with the threaded Odoo server too, although this way of running Odoo is obviously not for production purposes. + +* Be sure to check out *Jobs Garbage Collector* CRON and change *enqueued_delta* and *started_delta* parameters to your needs. + + * ``enqueued_delta``: Spent time in minutes after which an enqueued job is considered stuck. + Set it to 0 to disable this check. + * ``started_delta``: Spent time in minutes after which a started job is considered stuck. + This parameter should not be less than ``--limit-time-real // 60`` parameter in your configuration. + Set it to 0 to disable this check. Set it to -1 to automate it, based in the server's ``--limit-time-real`` config parameter. + + .. code-block:: python + + # `model` corresponds to 'queue.job' model + model.requeue_stuck_jobs(enqueued_delta=1, started_delta=-1) diff --git a/queue_job/static/description/index.html b/queue_job/static/description/index.html index 81f0620bc5..f72b5e5679 100644 --- a/queue_job/static/description/index.html +++ b/queue_job/static/description/index.html @@ -1,3 +1,4 @@ + @@ -8,10 +9,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +276,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +302,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -491,6 +493,21 @@

Configuration

of running Odoo is obviously not for production purposes. +

Usage

@@ -939,7 +956,9 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.