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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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.2.1.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> <a href='https://github.com/sbidoul'><img src='https://github.com/sbidoul.png' width='32' height='32' style='border-radius:50%;' alt='sbidoul'/></a> | Job Queue
[queue_job](queue_job/) | 18.0.3.0.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> <a href='https://github.com/sbidoul'><img src='https://github.com/sbidoul.png' width='32' height='32' style='border-radius:50%;' alt='sbidoul'/></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.1 | | Scheduled Actions as Queue Jobs
[queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 18.0.1.0.1 | <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
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:f0703a7128cfb08ec4af2ea8923d13ecb978cff638d0bbd923fdbb7f33d77af5
!! source digest: sha256:0b61ae169205114262bbac28e15c8729ea4056e5f2d2c08e8f38adbe479da264
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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.2.1.2",
"version": "18.0.3.0.0",
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "LGPL-3",
Expand Down
30 changes: 22 additions & 8 deletions queue_job/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from werkzeug.exceptions import BadRequest, Forbidden

from odoo import SUPERUSER_ID, _, api, http
from odoo.modules.registry import Registry
from odoo.service.model import PG_CONCURRENCY_ERRORS_TO_RETRY
from odoo.tools import config

from ..delay import chain, group
from ..exception import FailedJobError, RetryableJobError
Expand All @@ -38,8 +38,10 @@ def _prevent_commit(cr):
def forbidden_commit(*args, **kwargs):
raise RuntimeError(
"Commit is forbidden in queue jobs. "
"If the current job is a cron running as queue job, "
"modify it to run as a normal cron."
'You may want to enable the "Allow Commit" option on the Job '
"Function. Alternatively, if the current job is a cron running as "
"queue job, you can modify it to run as a normal cron. More details on: "
"https://github.com/OCA/queue/wiki/Upgrade-warning:-commits-inside-jobs"
)

original_commit = cr.commit
Expand Down Expand Up @@ -103,7 +105,8 @@ def _try_perform_job(cls, env, job):
job.set_done()
job.store()
env.flush_all()
env.cr.commit()
if not config["test_enable"]:
env.cr.commit()
_logger.debug("%s done", job)

@classmethod
Expand Down Expand Up @@ -146,8 +149,7 @@ def _enqueue_dependent_jobs(cls, env, job):
def _runjob(cls, env: api.Environment, job: Job) -> None:
def retry_postpone(job, message, seconds=None):
job.env.clear()
with Registry(job.env.cr.dbname).cursor() as new_cr:
job.env = api.Environment(new_cr, SUPERUSER_ID, {})
with job.in_temporary_env():
job.postpone(result=message, seconds=seconds)
job.set_pending(reset_retry=False)
job.store()
Expand Down Expand Up @@ -180,8 +182,7 @@ def retry_postpone(job, message, seconds=None):
traceback_txt = buff.getvalue()
_logger.error(traceback_txt)
job.env.clear()
with Registry(job.env.cr.dbname).cursor() as new_cr:
job.env = job.env(cr=new_cr)
with job.in_temporary_env():
vals = cls._get_failure_values(job, traceback_txt, orig_exception)
job.set_failed(**vals)
job.store()
Expand Down Expand Up @@ -233,6 +234,7 @@ def create_test_job(
failure_rate=0,
job_duration=0,
commit_within_job=False,
failure_retry_seconds=0,
):
if not http.request.env.user.has_group("base.group_erp_manager"):
raise Forbidden(_("Access Denied"))
Expand Down Expand Up @@ -270,6 +272,12 @@ def create_test_job(
except ValueError:
max_retries = None

if failure_retry_seconds is not None:
try:
failure_retry_seconds = int(failure_retry_seconds)
except ValueError:
failure_retry_seconds = 0

if size == 1:
return self._create_single_test_job(
priority=priority,
Expand All @@ -279,6 +287,7 @@ def create_test_job(
failure_rate=failure_rate,
job_duration=job_duration,
commit_within_job=commit_within_job,
failure_retry_seconds=failure_retry_seconds,
)

if size > 1:
Expand All @@ -291,6 +300,7 @@ def create_test_job(
failure_rate=failure_rate,
job_duration=job_duration,
commit_within_job=commit_within_job,
failure_retry_seconds=failure_retry_seconds,
)
return ""

Expand All @@ -304,6 +314,7 @@ def _create_single_test_job(
failure_rate=0,
job_duration=0,
commit_within_job=False,
failure_retry_seconds=0,
):
delayed = (
http.request.env["queue.job"]
Expand All @@ -317,6 +328,7 @@ def _create_single_test_job(
failure_rate=failure_rate,
job_duration=job_duration,
commit_within_job=commit_within_job,
failure_retry_seconds=failure_retry_seconds,
)
)
return f"job uuid: {delayed.db_record().uuid}"
Expand All @@ -333,6 +345,7 @@ def _create_graph_test_jobs(
failure_rate=0,
job_duration=0,
commit_within_job=False,
failure_retry_seconds=0,
):
model = http.request.env["queue.job"]
current_count = 0
Expand All @@ -359,6 +372,7 @@ def _create_graph_test_jobs(
failure_rate=failure_rate,
job_duration=job_duration,
commit_within_job=commit_within_job,
failure_retry_seconds=failure_retry_seconds,
)
)

Expand Down
17 changes: 15 additions & 2 deletions queue_job/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ msgstr "Aktivitätsstatus"
msgid "Activity Type Icon"
msgstr "Icon für Aktivitätstyp"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__allow_commit
msgid "Allow Commit"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__allow_commit
msgid ""
"Allows the job to commit transactions during execution. Under the hood, this "
"executes the job in a new database cursor, which incurs an overhead as it "
"requires an extra connection to the database. "
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__args
msgid "Args"
Expand Down Expand Up @@ -883,8 +896,8 @@ msgstr "UUID"
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
21 changes: 17 additions & 4 deletions queue_job/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ msgstr "Estado de la actividad"
msgid "Activity Type Icon"
msgstr "Icono de tipo de actividad"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__allow_commit
msgid "Allow Commit"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__allow_commit
msgid ""
"Allows the job to commit transactions during execution. Under the hood, this "
"executes the job in a new database cursor, which incurs an overhead as it "
"requires an extra connection to the database. "
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__args
msgid "Args"
Expand Down Expand Up @@ -895,13 +908,13 @@ msgstr "UUID"
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 ""
"Formato inesperado en la acción relacionada con {}.\n"
"Ejemplo de un formato válido:\n"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", "
"\"kwargs\" {{\"limit\": 10}}}}"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" "
"{{\"limit\": 10}}}}"

#. module: queue_job
#. odoo-python
Expand Down
21 changes: 17 additions & 4 deletions queue_job/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ msgstr "Stato attività"
msgid "Activity Type Icon"
msgstr "Icona tipo attività"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__allow_commit
msgid "Allow Commit"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__allow_commit
msgid ""
"Allows the job to commit transactions during execution. Under the hood, this "
"executes the job in a new database cursor, which incurs an overhead as it "
"requires an extra connection to the database. "
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__args
msgid "Args"
Expand Down Expand Up @@ -892,13 +905,13 @@ msgstr "UUID"
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 ""
"Formato inaspettato di azione colegata per {}.\n"
"Esempio di formato valido:\n"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", "
"\"kwargs\" {{\"limit\": 10}}}}"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" "
"{{\"limit\": 10}}}}"

#. module: queue_job
#. odoo-python
Expand Down
17 changes: 15 additions & 2 deletions queue_job/i18n/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ msgstr ""
msgid "Activity Type Icon"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__allow_commit
msgid "Allow Commit"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__allow_commit
msgid ""
"Allows the job to commit transactions during execution. Under the hood, this "
"executes the job in a new database cursor, which incurs an overhead as it "
"requires an extra connection to the database. "
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__args
msgid "Args"
Expand Down Expand Up @@ -866,8 +879,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
21 changes: 17 additions & 4 deletions queue_job/i18n/nl_NL.po
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ msgstr "Activiteitsstatus"
msgid "Activity Type Icon"
msgstr "Icoon activiteitstype"

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__allow_commit
msgid "Allow Commit"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__allow_commit
msgid ""
"Allows the job to commit transactions during execution. Under the hood, this "
"executes the job in a new database cursor, which incurs an overhead as it "
"requires an extra connection to the database. "
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__args
msgid "Args"
Expand Down Expand Up @@ -892,13 +905,13 @@ msgstr "UUID"
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 ""
"Onverwacht formaat van gerelateerde actie voor {}.\n"
"Voorbeeld van geldig formaat:\n"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", "
"\"kwargs\" {{\"limit\": 10}}}}"
"{{\"enable\": True, \"func_name\": \"related_action_foo\", \"kwargs\" "
"{{\"limit\": 10}}}}"

#. module: queue_job
#. odoo-python
Expand Down
13 changes: 13 additions & 0 deletions queue_job/i18n/queue_job.pot
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ msgstr ""
msgid "Activity Type Icon"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job_function__allow_commit
msgid "Allow Commit"
msgstr ""

#. module: queue_job
#: model:ir.model.fields,help:queue_job.field_queue_job_function__allow_commit
msgid ""
"Allows the job to commit transactions during execution. Under the hood, this"
" executes the job in a new database cursor, which incurs an overhead as it "
"requires an extra connection to the database. "
msgstr ""

#. module: queue_job
#: model:ir.model.fields,field_description:queue_job.field_queue_job__args
msgid "Args"
Expand Down
Loading
Loading