Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Available addons
addon | version | maintainers | summary
--- | --- | --- | ---
[base_import_async](base_import_async/) | 18.0.1.0.0 | | Import CSV files in the background
[queue_job](queue_job/) | 18.0.1.4.2 | <a href='https://github.com/guewen'><img src='https://github.com/guewen.png' width='32' height='32' style='border-radius:50%;' alt='guewen'/></a> | Job Queue
[queue_job](queue_job/) | 18.0.1.5.0 | <a href='https://github.com/guewen'><img src='https://github.com/guewen.png' width='32' height='32' style='border-radius:50%;' alt='guewen'/></a> | Job Queue
[queue_job_batch](queue_job_batch/) | 18.0.1.0.0 | | Job Queue Batch
[queue_job_cron](queue_job_cron/) | 18.0.1.1.0 | | Scheduled Actions as Queue Jobs
[queue_job_cron](queue_job_cron/) | 18.0.1.1.1 | | Scheduled Actions as Queue Jobs
[queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 18.0.1.0.0 | <a href='https://github.com/ivantodorovich'><img src='https://github.com/ivantodorovich.png' width='32' height='32' style='border-radius:50%;' alt='ivantodorovich'/></a> | Run jobs without a dedicated JobRunner
[queue_job_subscribe](queue_job_subscribe/) | 18.0.1.0.0 | | Control which users are subscribed to queue job notifications
[test_queue_job](test_queue_job/) | 18.0.1.0.1 | | Queue Job Tests
Expand Down
2 changes: 1 addition & 1 deletion queue_job/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Job Queue
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:285d0c064d250ff0c5b9e9c6ab4ced7664c95a34e09a39f0cf6838f441a36bb2
!! source digest: sha256:52a1fdc25fb3cff5edd8b3dab2375cc6508ef48fa70ee04d6f80b953611a1072
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
Expand Down
2 changes: 1 addition & 1 deletion queue_job/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "Job Queue",
"version": "18.0.1.4.2",
"version": "18.0.1.5.0",
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "LGPL-3",
Expand Down
1 change: 1 addition & 0 deletions queue_job/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ msgstr "Ausstehend"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search
msgid "Priority"
msgstr "Priorität"

Expand Down
1 change: 1 addition & 0 deletions queue_job/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ msgstr "Pendiente"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search
msgid "Priority"
msgstr "Prioridad"

Expand Down
1 change: 1 addition & 0 deletions queue_job/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ msgstr "In attesa"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search
msgid "Priority"
msgstr "Priorità"

Expand Down
1 change: 1 addition & 0 deletions queue_job/i18n/queue_job.pot
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search
msgid "Priority"
msgstr ""

Expand Down
16 changes: 12 additions & 4 deletions queue_job/i18n/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form
msgid ""
"<br/>\n"
" <span class=\"oe_grey oe_inline\"> If the max. retries is 0, the number of retries is infinite.</span>"
" <span class=\"oe_grey oe_inline\"> If the max. "
"retries is 0, the number of retries is infinite.</span>"
msgstr ""

#. module: queue_job
Expand Down Expand Up @@ -619,7 +620,10 @@ msgstr ""
#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__edit_retry_pattern
msgid ""
"Pattern expressing from the count of retries on retryable errors, the number of of seconds to postpone the next execution. Setting the number of seconds to a 2-element tuple or list will randomize the retry interval between the 2 values.\n"
"Pattern expressing from the count of retries on retryable errors, the number "
"of of seconds to postpone the next execution. Setting the number of seconds "
"to a 2-element tuple or list will randomize the retry interval between the 2 "
"values.\n"
"Example: {1: 10, 5: 20, 10: 30, 15: 300}.\n"
"Example: {1: (1, 10), 5: (11, 20), 10: (21, 30), 15: (100, 300)}.\n"
"See the module description for details."
Expand All @@ -633,6 +637,7 @@ msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search
msgid "Priority"
msgstr ""

Expand Down Expand Up @@ -813,7 +818,9 @@ msgstr ""
#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__edit_related_action
msgid ""
"The action when the button *Related Action* is used on a job. The default action is to open the view of the record related to the job. Configured as a dictionary with optional keys: enable, func_name, kwargs.\n"
"The action when the button *Related Action* is used on a job. The default "
"action is to open the view of the record related to the job. Configured as a "
"dictionary with optional keys: enable, func_name, kwargs.\n"
"See the module description for details."
msgstr ""

Expand Down Expand Up @@ -865,7 +872,8 @@ msgstr ""
msgid ""
"Unexpected format of Related Action for {}.\n"
"Example of valid format:\n"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" {{\"limit\": 10}}}}"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", "
"\"kwargs\" {{\"limit\": 10}}}}"
msgstr ""

#. module: queue_job
Expand Down
16 changes: 12 additions & 4 deletions queue_job/i18n/tr_TR.po
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_form
msgid ""
"<br/>\n"
" <span class=\"oe_grey oe_inline\"> If the max. retries is 0, the number of retries is infinite.</span>"
" <span class=\"oe_grey oe_inline\"> If the max. "
"retries is 0, the number of retries is infinite.</span>"
msgstr ""

#. module: queue_job
Expand Down Expand Up @@ -619,7 +620,10 @@ msgstr ""
#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__edit_retry_pattern
msgid ""
"Pattern expressing from the count of retries on retryable errors, the number of of seconds to postpone the next execution. Setting the number of seconds to a 2-element tuple or list will randomize the retry interval between the 2 values.\n"
"Pattern expressing from the count of retries on retryable errors, the number "
"of of seconds to postpone the next execution. Setting the number of seconds "
"to a 2-element tuple or list will randomize the retry interval between the 2 "
"values.\n"
"Example: {1: 10, 5: 20, 10: 30, 15: 300}.\n"
"Example: {1: (1, 10), 5: (11, 20), 10: (21, 30), 15: (100, 300)}.\n"
"See the module description for details."
Expand All @@ -633,6 +637,7 @@ msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search
msgid "Priority"
msgstr ""

Expand Down Expand Up @@ -813,7 +818,9 @@ msgstr ""
#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__edit_related_action
msgid ""
"The action when the button *Related Action* is used on a job. The default action is to open the view of the record related to the job. Configured as a dictionary with optional keys: enable, func_name, kwargs.\n"
"The action when the button *Related Action* is used on a job. The default "
"action is to open the view of the record related to the job. Configured as a "
"dictionary with optional keys: enable, func_name, kwargs.\n"
"See the module description for details."
msgstr ""

Expand Down Expand Up @@ -865,7 +872,8 @@ msgstr ""
msgid ""
"Unexpected format of Related Action for {}.\n"
"Example of valid format:\n"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" {{\"limit\": 10}}}}"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", "
"\"kwargs\" {{\"limit\": 10}}}}"
msgstr ""

#. module: queue_job
Expand Down
1 change: 1 addition & 0 deletions queue_job/i18n/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ msgstr "等待"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__priority
#: model_terms:ir.ui.view,arch_db:queue_job.view_queue_job_search
msgid "Priority"
msgstr "优先级"

Expand Down
11 changes: 11 additions & 0 deletions queue_job/jobrunner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,17 @@ def __init__(
self._stop = False
self._stop_pipe = os.pipe()

def __del__(self):
# pylint: disable=except-pass
try:
os.close(self._stop_pipe[0])
except OSError:
pass
try:
os.close(self._stop_pipe[1])
except OSError:
pass

@classmethod
def from_environ_or_config(cls):
scheme = os.environ.get("ODOO_QUEUE_JOB_SCHEME") or queue_job_config.get(
Expand Down
2 changes: 1 addition & 1 deletion queue_job/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class QueueJob(models.Model):
func_string = fields.Char(string="Task", readonly=True)

state = fields.Selection(STATES, readonly=True, required=True, index=True)
priority = fields.Integer()
priority = fields.Integer(aggregator=False)
exc_name = fields.Char(string="Exception", readonly=True)
exc_message = fields.Char(string="Exception Message", readonly=True, tracking=True)
exc_info = fields.Text(string="Exception Info", readonly=True)
Expand Down
2 changes: 1 addition & 1 deletion queue_job/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Job Queue</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:285d0c064d250ff0c5b9e9c6ab4ced7664c95a34e09a39f0cf6838f441a36bb2
!! source digest: sha256:52a1fdc25fb3cff5edd8b3dab2375cc6508ef48fa70ee04d6f80b953611a1072
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/18.0/queue_job"><img alt="OCA/queue" src="https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/queue-18-0/queue-18-0-queue_job"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/queue&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon adds an integrated Job Queue to Odoo.</p>
Expand Down
49 changes: 49 additions & 0 deletions queue_job/tests/test_runner_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,57 @@

# pylint: disable=odoo-addons-relative-import
# we are testing, we want to test as we were an external consumer of the API
import os

from odoo.tests import BaseCase, tagged

from odoo.addons.queue_job.jobrunner import runner

from .common import load_doctests

load_tests = load_doctests(runner)


@tagged("-at_install", "post_install")
class TestRunner(BaseCase):
@classmethod
def _is_open_file_descriptor(cls, fd):
try:
os.fstat(fd)
return True
except OSError:
return False

def test_runner_file_descriptor(self):
a_runner = runner.QueueJobRunner.from_environ_or_config()

read_fd, write_fd = a_runner._stop_pipe
self.assertTrue(self._is_open_file_descriptor(read_fd))
self.assertTrue(self._is_open_file_descriptor(write_fd))

del a_runner

self.assertFalse(self._is_open_file_descriptor(read_fd))
self.assertFalse(self._is_open_file_descriptor(write_fd))

def test_runner_file_closed_read_descriptor(self):
a_runner = runner.QueueJobRunner.from_environ_or_config()

read_fd, write_fd = a_runner._stop_pipe
os.close(read_fd)

del a_runner

self.assertFalse(self._is_open_file_descriptor(read_fd))
self.assertFalse(self._is_open_file_descriptor(write_fd))

def test_runner_file_closed_write_descriptor(self):
a_runner = runner.QueueJobRunner.from_environ_or_config()

read_fd, write_fd = a_runner._stop_pipe
os.close(write_fd)

del a_runner

self.assertFalse(self._is_open_file_descriptor(read_fd))
self.assertFalse(self._is_open_file_descriptor(write_fd))
7 changes: 7 additions & 0 deletions queue_job/views/queue_job_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<!-- pylint: disable=duplicate-xml-fields -->
<field name="date_done" />
<field name="exec_time" />
<field name="priority" optional="hide" />
<field name="exc_name" />
<field name="exc_message" />
<field name="uuid" />
Expand Down Expand Up @@ -207,6 +208,7 @@
<field name="channel" />
<field name="job_function_id" />
<field name="model_name" />
<field name="priority" />
<field name="exc_name" />
<field name="exc_message" />
<field name="exc_info" />
Expand Down Expand Up @@ -279,6 +281,11 @@
string="State"
context="{'group_by': 'state'}"
/>
<filter
name="group_by_priority"
string="Priority"
context="{'group_by': 'priority'}"
/>
<filter
name="group_by_model_name"
string="Model"
Expand Down
8 changes: 6 additions & 2 deletions queue_job_cron/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===============================
Scheduled Actions as Queue Jobs
===============================
Expand All @@ -7,13 +11,13 @@ Scheduled Actions as Queue Jobs
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f60ceee0fe0f89efc0c8e032cecd8fab6b3cd80fde8f419fd5b99f8563a892b1
!! source digest: sha256:61571266d30481c36fe1d1751209760e580f0fdd528d8a39b9610f37a442c920
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github
Expand Down
2 changes: 1 addition & 1 deletion queue_job_cron/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Scheduled Actions as Queue Jobs",
"version": "18.0.1.1.0",
"version": "18.0.1.1.1",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "AGPL-3",
Expand Down
10 changes: 5 additions & 5 deletions queue_job_cron/models/ir_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def method_direct_trigger(self):
)
return True

def _callback(self, cron_name, server_action_id, job_id):
cron = self.env["ir.cron"].sudo().browse(job_id)
if cron.run_as_queue_job:
def _callback(self, cron_name, server_action_id):
self.ensure_one()
if self.run_as_queue_job:
server_action = self.env["ir.actions.server"].browse(server_action_id)
return cron._delay_run_job_as_queue_job(server_action=server_action)
return self._delay_run_job_as_queue_job(server_action=server_action)
else:
return super()._callback(
cron_name=cron_name, server_action_id=server_action_id, job_id=job_id
cron_name=cron_name, server_action_id=server_action_id
)

def _delay_run_job_as_queue_job(self, server_action):
Expand Down
Loading