Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] queue_job_cron: Migration to 17.0 #1

Open
wants to merge 1,247 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
1247 commits
Select commit Hold shift + click to select a range
e3f01b0
Escape strings passed to the graph js widget
guewen Jul 21, 2021
a34078f
Fix things required by odoo 14.0 or python 3.9
guewen Oct 26, 2022
08a0951
Add documentation about handling of failures in a graph
guewen Jan 29, 2022
f57efbd
Fix equality of enqueued jobs
guewen Feb 2, 2022
0ec407e
Use a python3.6 compatible data class
guewen Feb 2, 2022
02d1f8f
Rename mock_jobs() to trap_jobs()
guewen Feb 3, 2022
60ca441
Rename dependency method done() to on_done()
guewen Feb 3, 2022
e257060
Migrate queue job graph/dependencies to 15.0
guewen Oct 24, 2022
da82ed3
Apply pre-commit on migration of jobs graph
guewen Oct 24, 2022
bed371b
[UPD] Update queue_job.pot
Nov 15, 2022
8c114fd
[UPD] README.rst
OCA-git-bot Nov 15, 2022
38ab83c
Update translation files
weblate Nov 15, 2022
bdad9c9
[MIG] queue_job, test_queue_job: Forward port queue from 15.0
lmignon Nov 16, 2022
9016a67
[FIX] queue_job: fix invalid po files
lmignon Nov 22, 2022
24e33db
[UPD] Update queue_job.pot
Nov 22, 2022
6cb22e2
queue_job 16.0.2.0.0
OCA-git-bot Nov 22, 2022
c4854fd
Update translation files
weblate Nov 22, 2022
c276ec5
[FIX] queue_job: UI glitches in 16.0 migration
StefanRijnhart Dec 14, 2022
b9e4627
[UPD] Update queue_job.pot
Dec 14, 2022
c860bbb
queue_job 16.0.2.1.0
OCA-git-bot Dec 14, 2022
bf3046a
Update translation files
weblate Dec 14, 2022
ddb8a4d
[FIX] Patch Request._get_session_and_dbname to get db from URL
hugosantosred Jan 31, 2023
6cec77b
[FIX] queue_job: Commit was removed, but that could be a problem if y…
etobella Feb 14, 2023
8712495
Translated using Weblate (Spanish)
FranciscoFactorLibre Feb 15, 2023
cd301cb
[FIX] queue_job: delayable representation failed
etobella Dec 1, 2022
4376bb2
Fix cursor already closed error on retryable errors
guewen Jun 21, 2022
e901be2
[IMP] queue_job: add configuration options for
repodevs Nov 2, 2022
d965c03
[14.0][FIX] queue_job: fix read
sanchonuria Feb 9, 2023
21f3c5c
queue_job 16.0.2.2.0
OCA-git-bot Feb 28, 2023
6692e96
queue_job: unify no delay option
simahawk Feb 28, 2023
258874d
queue_job 16.0.2.2.1
OCA-git-bot Mar 29, 2023
67655e1
[UPD] README.rst
OCA-git-bot Apr 2, 2023
0e5a50b
queue_job 16.0.2.3.0
OCA-git-bot Apr 2, 2023
6b6ccde
Handle cancelled state in job runner
sbidoul May 2, 2023
e6699a9
queue_job 16.0.2.3.1
OCA-git-bot May 4, 2023
d79cfac
Fix trap_jobs() recordset comparison
guewen May 9, 2023
16f6193
Translated using Weblate (Spanish)
ramiadavid May 18, 2023
f3053ea
Translated using Weblate (Spanish)
ramiadavid May 18, 2023
77cb4e8
queue_job 16.0.2.3.2
OCA-git-bot Jun 2, 2023
230f4b0
queue_job 16.0.2.4.0
OCA-git-bot Jun 2, 2023
0c7ab9f
[FIX] queue_job: runner - filedescriptor out of range in select
moylop260 Feb 15, 2022
c0427c1
queue_job 16.0.2.5.0
OCA-git-bot Jun 30, 2023
6741071
[UPD] Update queue_job.pot
Sep 3, 2023
fad27f2
[UPD] README.rst
OCA-git-bot Sep 3, 2023
5dce1a5
Update translation files
weblate Sep 3, 2023
acb5985
Translated using Weblate (Spanish)
Ivorra78 Sep 7, 2023
da0844e
Translated using Weblate (Spanish)
Ivorra78 Sep 20, 2023
17c1960
[UPD] Update queue_job.pot
Oct 28, 2023
2e83ab6
Update translation files
weblate Oct 29, 2023
e4284bc
[IMP] queue_job: identity_key enhancements
Jun 16, 2023
b50a377
queue_job: job_record_with_same_identity_key ignore STARTED
simahawk Nov 21, 2023
03414a8
FIX queue_job avoiding AccessDenied when loading the module in an ins…
eLBati Oct 26, 2021
d0c22ce
queue job avoiding AccessDenied when loading the module in an instanc…
pcastelovigo Nov 22, 2023
89df542
[BOT] post-merge updates
OCA-git-bot Nov 23, 2023
bf2b504
[BOT] post-merge updates
OCA-git-bot Nov 23, 2023
b919821
[IMP] queue_job: pre-commit auto fixes
nguyenminhchien Nov 29, 2023
d0e7497
[ADD] queue_job_cron_jobrunner
ivantodorovich Mar 2, 2022
544e127
[UPD] Update queue_job_cron_jobrunner.pot
Apr 11, 2022
9c9972b
[UPD] README.rst
OCA-git-bot Apr 11, 2022
355c9d6
[ADD] icon.png
OCA-git-bot Apr 11, 2022
2364d8f
Initialize 16.0
sbidoul Oct 3, 2022
ea2d7b8
Add enqueue of graph dependencies in queue_job_cron_jobrunner
guewen Nov 1, 2022
57a6acf
queue_job_cron_jobrunner 15.0.2.0.0
OCA-git-bot Nov 15, 2022
526b2c8
Added translation using Weblate (Romanian)
dhongu Nov 23, 2022
d41876a
Translated using Weblate (Romanian)
dhongu Nov 23, 2022
c3fc44e
[MIG] queue_job_cron_jobrunner: Migration to 16.0
nilshamerlinck Dec 14, 2022
7378fe3
[UPD] Update queue_job_cron_jobrunner.pot
Feb 20, 2023
0c15468
[UPD] README.rst
OCA-git-bot Feb 20, 2023
ba9dbb5
[UPD] README.rst
OCA-git-bot Sep 3, 2023
e786195
Update translation files
weblate Oct 9, 2023
87eb6f0
[IMP] queue_job_cron_jobrunner: pre-commit auto fixes
sanderlienaerts Dec 1, 2023
cf0e991
Make tests pass
guewen Dec 29, 2016
acc72e0
Fix implementation of related actions
guewen Dec 29, 2016
acf5c2f
Move tests using queue_job.testing_method in test_queue_job
guewen Dec 30, 2016
23bfdb0
Fix mutability of job arguments
guewen Jan 2, 2017
6518065
[IMP] Allow to override the channel to use when delaying a job
lmignon Mar 29, 2017
cfb0242
[FIX] domain to subscribe users
GillesTephaneMeyomesse May 26, 2017
f480e8b
[MIG] Make modules uninstallable
pedrobaeza Oct 2, 2017
34037d7
Set test_queue_job installable to work on tests
guewen Oct 2, 2017
d02bc5d
PY3: replace im_class and so with __self__
guewen Oct 2, 2017
a5a4371
PY3: remove encode/decode in a test
guewen Oct 2, 2017
ac55783
Correct or disable pylint warnings
guewen May 25, 2018
cd2a1de
Fix auto registration of job methods and channels
guewen May 22, 2018
10535a9
Add default related action to open related records
guewen Jan 24, 2018
aee6178
[MIG] Make modules uninstallable
OCA-git-bot Sep 27, 2018
9eb6df0
Migrate queue_job to 12.0
guewen Oct 1, 2018
400caa9
[11.0] Forward port. of identity_key (from 10.0)
guewen Jun 28, 2018
e076a02
[UPD] Update test_queue_job.pot
oca-travis Dec 13, 2018
2d34369
[ADD] icon.png
OCA-git-bot Apr 2, 2019
6725e35
[ADD] Test case for "AutoVacuum Job Queue" cron job
Aug 3, 2019
fd19ed8
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Aug 31, 2019
7462080
Translated using Weblate (Chinese (Simplified))
liweijie0812 Aug 31, 2019
6a73a04
Set modules as uninstallable
guewen Oct 1, 2019
018a097
Migrate queue_job
guewen Oct 1, 2019
dc500aa
Replace sudo(user) by with_user(user)
guewen Oct 1, 2019
c41b8f7
Run pre-commit with black, isort, ...
guewen Oct 4, 2019
a4e7995
[UPD] Update test_queue_job.pot
oca-travis Oct 15, 2019
2772a97
Use more permissive license AGPL3 → LGPL3
guewen Oct 31, 2019
63ed9e2
queue_job: allow to define vacuum removal interval per channel
Nov 7, 2019
484919d
Move autovacuum tests in the same class
guewen Nov 8, 2019
1f87ac1
[FIX] queue_job: vaccuum query must be based on channel complete name
Nov 27, 2019
d4550e0
Store worker's PID when a job is started
guewen Oct 1, 2020
9037f1d
Deprecate job decorators
guewen Oct 30, 2020
2a4ca5a
Replace job function name by model + method fields
guewen Nov 2, 2020
054ea2b
test_queue_job 13.0.2.0.0
OCA-git-bot Nov 12, 2020
37d1af7
test_queue_job 13.0.2.1.0
OCA-git-bot Nov 13, 2020
b935818
Refactor user_id,model_name,record_ids fields on queue.job
guewen Oct 29, 2020
bc11fbf
Store 'su' flag in records stored in JobSerialized fields
guewen Nov 13, 2020
aaa66fb
[MIG] init V14 repo
sebastienbeau Nov 20, 2020
8299cf7
[IMP] : black, isort, prettier
sebastienbeau Nov 20, 2020
2c9a85a
[REF] remove deprecated feature
sebastienbeau Nov 20, 2020
ecfc054
[MIG] finish migration
sebastienbeau Nov 20, 2020
25dff8a
Add import shortcut for identity_exact
guewen Nov 28, 2020
bb49e61
[UPD] Update test_queue_job.pot
oca-travis Nov 30, 2020
70d0429
[REF] Replace deprecated assertEquals with assertEqual
PieterPaulussen Mar 23, 2021
0791f4b
[FIX] use __func__ for function comparison in tests
PieterPaulussen Apr 6, 2021
f73fd59
[IMP] Store job execution information + wizard to terminate a job + test
PieterPaulussen Mar 23, 2021
beb5c45
[ADD] Apply suggestions from code review
Apr 20, 2021
ef3cef6
[UPD] Update test_queue_job.pot
oca-travis May 4, 2021
4a45797
test_queue_job 14.0.1.1.0
OCA-git-bot May 4, 2021
33b0740
Update translation files
oca-transbot May 4, 2021
fa53f27
Revert "[14.0] [IMP] Store job execution information + wizard to term…
guewen May 11, 2021
d17f54f
[UPD] Update test_queue_job.pot
oca-travis May 12, 2021
a1c39e9
test_queue_job 14.0.1.2.0
OCA-git-bot May 12, 2021
edeb45a
Update translation files
oca-transbot May 12, 2021
6caa121
Add method to patch a method to be automatically delayed
guewen Oct 28, 2020
0371a57
test_queue_job 14.0.1.3.0
OCA-git-bot May 27, 2021
403c0c4
Set modules as uninstallable
guewen Nov 1, 2021
c0de15d
Set modules queue_job and test_queue_job as installable
guewen Nov 1, 2021
8148771
Run pre-commit run -a
guewen Nov 1, 2021
552e961
[MIG] test_queue_job: Migration to 15.0
guewen Nov 1, 2021
444950c
[UPD] Update test_queue_job.pot
Nov 2, 2021
88a3b1d
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 31, 2022
1755e2d
Initialize 16.0
sbidoul Oct 3, 2022
0b165f9
[MIG] test_queue_job: Migration to 16.0
baimont Oct 11, 2022
80b533a
[FIX] import mock from unittest
baimont Oct 11, 2022
b06680a
[UPD] Update test_queue_job.pot
Oct 11, 2022
003dbf0
[UPD] Update test_queue_job.pot
Oct 18, 2022
ef53d43
Update translation files
weblate Oct 18, 2022
442df9d
Disable storing of context in jobs recordsets by default
guewen May 12, 2022
ffb9920
test_queue_job 16.0.1.0.1
OCA-git-bot Oct 26, 2022
cbd29b9
Added translation using Weblate (German)
marylla Nov 4, 2022
e632e1c
Translated using Weblate (German)
marylla Nov 4, 2022
87ad457
Remove initial create notification and follower
guewen Feb 1, 2021
8497a81
queue_job: add exec time to view some stats
simahawk Feb 8, 2021
6c292d7
queue_job: add hook to customize stored values
simahawk Mar 29, 2021
e3aba02
queue_job: store exception name and message
simahawk Mar 29, 2021
8032dce
[UPD] Update test_queue_job.pot
Oct 31, 2022
6cf89cb
Update translation files
weblate Oct 31, 2022
9812291
Store dependencies
guewen Jul 2, 2019
59ec1c0
Add wait dependencies state
guewen Jul 2, 2019
7ad95b1
Add API for Delayables
guewen Jul 5, 2019
431b1b2
Add a graph UUID
guewen May 26, 2021
99c03a1
Ignore requeues on dependency jobs waiting on parent jobs
guewen May 26, 2021
e262e37
Fix warnings in tests
guewen May 27, 2021
b974e1c
Improve display of jobs graph widget
guewen May 27, 2021
b0bc513
Add powerful context manager for running tests on jobs
guewen May 28, 2021
d120e48
Set graph_uuid only once in DelayableGraph
guewen May 30, 2021
4cbc103
Add docstrings on the new delayable classes
guewen May 30, 2021
a4c7318
Fix things required by odoo 14.0 or python 3.9
guewen Oct 26, 2022
dca7b11
Rename mock_jobs() to trap_jobs()
guewen Feb 3, 2022
eb172a7
Rename dependency method done() to on_done()
guewen Feb 3, 2022
ccad49f
Apply pre-commit on migration of jobs graph
guewen Oct 24, 2022
1b4f6f2
Use new TransactionCase instead of deprecated SavepointCase
guewen Oct 24, 2022
a3b8f83
[MIG] queue_job, test_queue_job: Forward port queue from 15.0
lmignon Nov 16, 2022
5767a10
test_queue_job 16.0.2.0.0
OCA-git-bot Nov 22, 2022
d513861
Update translation files
weblate Nov 22, 2022
3cf3d8c
queue_job: unify no delay option
simahawk Feb 28, 2023
1f3ae3a
test_queue_job 16.0.2.1.0
OCA-git-bot Apr 2, 2023
30fa6cb
Fix trap_jobs() recordset comparison
guewen May 9, 2023
5891173
test_queue_job 16.0.2.2.0
OCA-git-bot Jun 2, 2023
c1357ff
Added translation using Weblate (Spanish)
Ivorra78 Oct 15, 2023
6b9c39d
Translated using Weblate (Spanish)
Ivorra78 Oct 15, 2023
740f39f
[IMP] queue_job: identity_key enhancements
Jun 16, 2023
8a9c63d
[BOT] post-merge updates
OCA-git-bot Nov 23, 2023
aabbceb
[IMP] test_queue_job: pre-commit auto fixes
nguyenminhchien Nov 29, 2023
dc35a81
[MIG] test_queue_job: Migration to 17.0
nguyenminhchien Nov 29, 2023
686691b
[MIG] queue_job: Migration to 17.0
nguyenminhchien Dec 4, 2023
3d5b74b
Merge PR #593 into 17.0
OCA-git-bot Dec 5, 2023
b92f7b6
[UPD] Update queue_job.pot
Dec 5, 2023
f1cc840
[UPD] Update test_queue_job.pot
Dec 5, 2023
a70fda8
[BOT] post-merge updates
OCA-git-bot Dec 5, 2023
b9722f9
[MIG] queue_job_cron_jobrunner: Migration to 17.0
sanderlienaerts Dec 6, 2023
4827b13
Merge PR #604 into 17.0
OCA-git-bot Dec 13, 2023
f0f68f6
[UPD] Update queue_job_cron_jobrunner.pot
Dec 13, 2023
5b7a26f
[BOT] post-merge updates
OCA-git-bot Dec 13, 2023
c9e0ba9
[MIG] queue_job_subscribe 10.0
sbidoul Sep 12, 2017
443b1c8
[IMP] queue_job_subscribe: style
sbidoul Sep 12, 2017
3e38457
[IMP] queue_job_subscribe: odoo tag in views
sbidoul Sep 12, 2017
137da22
[IMP] queue_job_subscribe: improve README
sbidoul Sep 13, 2017
5b72721
[MIG] Make modules uninstallable
pedrobaeza Oct 2, 2017
c1a2ca3
Migrate queue_job_subscribe to v11
guewen Oct 3, 2017
f79ca5e
Correct or disable pylint warnings
guewen May 25, 2018
e1c3300
[MIG] Make modules uninstallable
OCA-git-bot Sep 27, 2018
7b56fcd
Migrate queue_job_subscribe to 13.0
guewen Oct 1, 2019
ef414ba
Run pre-commit with black, isort, ...
guewen Oct 4, 2019
99a363a
pre-commit update
OCA-git-bot Mar 7, 2020
c4504ba
[MIG] init V14 repo
sebastienbeau Nov 20, 2020
c72b92f
[IMP] : black, isort, prettier
sebastienbeau Nov 20, 2020
5f38380
[14.0][MIG] - queue_job_subscribe
sbejaoui Jul 9, 2021
c841abb
[MIG] queue_job_subscribe: Migration to 15.0
SilvioC2C Jun 30, 2022
28dd8a8
[MIG] queue_job_subscribe: Migration to 16.0
ramiadavid May 26, 2023
4cb2fc6
[IMP] queue_job_subscribe: pre-commit auto fixes
ramiadavid Dec 12, 2023
a85be74
[MIG] queue_job_subscribe: Migration to 17.0
ramiadavid Dec 12, 2023
ce7271d
Merge PR #605 into 17.0
OCA-git-bot Jan 8, 2024
4bda4c2
[UPD] Update queue_job_subscribe.pot
Jan 8, 2024
b51243c
[BOT] post-merge updates
OCA-git-bot Jan 8, 2024
e3bae7d
[ADD] add new module to execute ir_cron as queue_job
Dec 20, 2017
8cf393c
Improve tests coverage
Dec 21, 2017
f3ebd8a
queue_job_cron: do not require read access to ir.cron
sbidoul Feb 9, 2018
7bef6f3
queue_job_cron: bump version
sbidoul Feb 13, 2018
618127c
[MIG] Queue Job Cron to 12.0
ThomasBinsfeld Jan 8, 2019
10ead11
[UPD] Update queue_job_cron.pot
oca-travis Mar 15, 2019
43541da
[ADD] icon.png
OCA-git-bot Apr 2, 2019
8232e11
Added translation using Weblate (German)
marylla Jul 4, 2019
cc03126
Translated using Weblate (German)
marylla Jul 12, 2019
574e559
Added translation using Weblate (Chinese (Simplified))
liweijie0812 Jul 25, 2019
c240bf6
Translated using Weblate (Chinese (Simplified))
liweijie0812 Jul 25, 2019
6afb38b
[UPD] README.rst
OCA-git-bot Jul 29, 2019
062e15a
Rename Chinese translation files
liweijie0812 Aug 30, 2019
e5558f6
Set modules as uninstallable
guewen Oct 1, 2019
2bb5b89
Migrate queue_job_cron to 13.0
guewen Oct 1, 2019
e5c212a
Run pre-commit with black, isort, ...
guewen Oct 4, 2019
b571536
[UPD] Update queue_job_cron.pot
oca-travis Oct 15, 2019
e45997d
[UPD] README.rst
OCA-git-bot Oct 15, 2019
f6e48c6
pre-commit update
OCA-git-bot Mar 7, 2020
a1fdaa0
queue_job_cron: remove `@job` decorator
guewen Nov 2, 2020
7cd01bd
queue_job_cron 13.0.2.0.0
OCA-git-bot Nov 12, 2020
f76be89
Fix channel name in jobs delayed for crons
guewen Nov 6, 2020
b6af054
queue_job_cron 13.0.2.1.0
OCA-git-bot Nov 20, 2020
8dc435b
[MIG] init V14 repo
sebastienbeau Nov 20, 2020
93d3e8c
[IMP] : black, isort, prettier
sebastienbeau Nov 20, 2020
bbe9946
[MIG] Bump version. Set module installable. Check migration guide.
codingforfun Feb 25, 2021
612cf9a
[FIX] Respect `cron.user_id` for manually triggered queue jobs
codingforfun Feb 25, 2021
bbd0f19
[UPD] Update queue_job_cron.pot
oca-travis Apr 22, 2021
a9e96e1
[UPD] README.rst
OCA-git-bot Apr 22, 2021
15671a8
Set modules as uninstallable
guewen Nov 1, 2021
edf6630
[MIG][15.0] queue_job_cron to version 15.0
JoanMForgeFlow Mar 1, 2022
694c9c4
[UPD] Update queue_job_cron.pot
Apr 29, 2022
6cf2c1e
[UPD] README.rst
OCA-git-bot Apr 29, 2022
07d3e68
Initialize 16.0
sbidoul Oct 3, 2022
b67c01a
[MIG][15.0] queue_job_cron to version 15.0
JoanMForgeFlow Mar 1, 2022
370d69a
[MIG] queue_job_cron: Migration to 16.0
baimont Aug 31, 2022
08e1cae
[UPD] README.rst
OCA-git-bot Nov 22, 2022
4c00f83
Added translation using Weblate (Spanish)
kikopeiro Aug 29, 2023
8d42c95
[UPD] README.rst
OCA-git-bot Sep 3, 2023
f29221f
Translated using Weblate (Spanish)
kikopeiro Aug 29, 2023
ab8e78a
Update translation files
weblate Oct 9, 2023
e6225a0
[IMP] queue_job_cron: Pre-commit auto fixes
nguyenminhchien Jan 10, 2024
0372db7
[MIG] queue_job_cron: Migration to 17.0
nguyenminhchien Jan 10, 2024
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
677 changes: 677 additions & 0 deletions queue_job/README.rst

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions queue_job/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from . import controllers
from . import fields
from . import models
from . import wizards
from . import jobrunner
from .post_init_hook import post_init_hook
from .post_load import post_load

# shortcuts
from .job import identity_exact
35 changes: 35 additions & 0 deletions queue_job/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

{
"name": "Job Queue",
"version": "17.0.1.0.0",
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "LGPL-3",
"category": "Generic Modules",
"depends": ["mail", "base_sparse_field", "web"],
"external_dependencies": {"python": ["requests"]},
"data": [
"security/security.xml",
"security/ir.model.access.csv",
"views/queue_job_views.xml",
"views/queue_job_channel_views.xml",
"views/queue_job_function_views.xml",
"wizards/queue_jobs_to_done_views.xml",
"wizards/queue_jobs_to_cancelled_views.xml",
"wizards/queue_requeue_job_views.xml",
"views/queue_job_menus.xml",
"data/queue_data.xml",
"data/queue_job_function_data.xml",
],
"assets": {
"web.assets_backend": [
"/queue_job/static/src/views/**/*",
],
},
"installable": True,
"development_status": "Mature",
"maintainers": ["guewen"],
"post_init_hook": "post_init_hook",
"post_load": "post_load",
}
1 change: 1 addition & 0 deletions queue_job/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
297 changes: 297 additions & 0 deletions queue_job/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
# Copyright (c) 2015-2016 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2013-2016 Camptocamp SA
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)

import logging
import random
import time
import traceback
from io import StringIO

from psycopg2 import OperationalError, errorcodes
from werkzeug.exceptions import BadRequest, Forbidden

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

from ..delay import chain, group
from ..exception import FailedJobError, NothingToDoJob, RetryableJobError
from ..job import ENQUEUED, Job

_logger = logging.getLogger(__name__)

PG_RETRY = 5 # seconds

DEPENDS_MAX_TRIES_ON_CONCURRENCY_FAILURE = 5


class RunJobController(http.Controller):
def _try_perform_job(self, env, job):
"""Try to perform the job."""
job.set_started()
job.store()
env.cr.commit()
_logger.debug("%s started", job)

job.perform()
job.set_done()
job.store()
env.flush_all()
env.cr.commit()
_logger.debug("%s done", job)

def _enqueue_dependent_jobs(self, env, job):
tries = 0
while True:
try:
job.enqueue_waiting()
except OperationalError as err:
# Automatically retry the typical transaction serialization
# errors
if err.pgcode not in PG_CONCURRENCY_ERRORS_TO_RETRY:
raise
if tries >= DEPENDS_MAX_TRIES_ON_CONCURRENCY_FAILURE:
_logger.info(
"%s, maximum number of tries reached to update dependencies",
errorcodes.lookup(err.pgcode),
)
raise
wait_time = random.uniform(0.0, 2**tries)
tries += 1
_logger.info(
"%s, retry %d/%d in %.04f sec...",
errorcodes.lookup(err.pgcode),
tries,
DEPENDS_MAX_TRIES_ON_CONCURRENCY_FAILURE,
wait_time,
)
time.sleep(wait_time)
else:
break

@http.route("/queue_job/runjob", type="http", auth="none", save_session=False)
def runjob(self, db, job_uuid, **kw):
http.request.session.db = db
env = http.request.env(user=SUPERUSER_ID)

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, {})
job.postpone(result=message, seconds=seconds)
job.set_pending(reset_retry=False)
job.store()

# ensure the job to run is in the correct state and lock the record
env.cr.execute(
"SELECT state FROM queue_job WHERE uuid=%s AND state=%s FOR UPDATE",
(job_uuid, ENQUEUED),
)
if not env.cr.fetchone():
_logger.warning(
"was requested to run job %s, but it does not exist, "
"or is not in state %s",
job_uuid,
ENQUEUED,
)
return ""

job = Job.load(env, job_uuid)
assert job and job.state == ENQUEUED

try:
try:
self._try_perform_job(env, job)
except OperationalError as err:
# Automatically retry the typical transaction serialization
# errors
if err.pgcode not in PG_CONCURRENCY_ERRORS_TO_RETRY:
raise

_logger.debug("%s OperationalError, postponed", job)
raise RetryableJobError(
tools.ustr(err.pgerror, errors="replace"), seconds=PG_RETRY
) from err

except NothingToDoJob as err:
if str(err):
msg = str(err)
else:
msg = _("Job interrupted and set to Done: nothing to do.")
job.set_done(msg)
job.store()
env.cr.commit()

except RetryableJobError as err:
# delay the job later, requeue
retry_postpone(job, str(err), seconds=err.seconds)
_logger.debug("%s postponed", job)
# Do not trigger the error up because we don't want an exception
# traceback in the logs we should have the traceback when all
# retries are exhausted
env.cr.rollback()
return ""

except (FailedJobError, Exception) as orig_exception:
buff = StringIO()
traceback.print_exc(file=buff)
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)
vals = self._get_failure_values(job, traceback_txt, orig_exception)
job.set_failed(**vals)
job.store()
buff.close()
raise

_logger.debug("%s enqueue depends started", job)
self._enqueue_dependent_jobs(env, job)
_logger.debug("%s enqueue depends done", job)

return ""

def _get_failure_values(self, job, traceback_txt, orig_exception):
"""Collect relevant data from exception."""
exception_name = orig_exception.__class__.__name__
if hasattr(orig_exception, "__module__"):
exception_name = orig_exception.__module__ + "." + exception_name
exc_message = getattr(orig_exception, "name", str(orig_exception))
return {
"exc_info": traceback_txt,
"exc_name": exception_name,
"exc_message": exc_message,
}

# flake8: noqa: C901
@http.route("/queue_job/create_test_job", type="http", auth="user")
def create_test_job(
self,
priority=None,
max_retries=None,
channel=None,
description="Test job",
size=1,
failure_rate=0,
):
if not http.request.env.user.has_group("base.group_erp_manager"):
raise Forbidden(_("Access Denied"))

if failure_rate is not None:
try:
failure_rate = float(failure_rate)
except (ValueError, TypeError):
failure_rate = 0

if not (0 <= failure_rate <= 1):
raise BadRequest("failure_rate must be between 0 and 1")

if size is not None:
try:
size = int(size)
except (ValueError, TypeError):
size = 1

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

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

if size == 1:
return self._create_single_test_job(
priority=priority,
max_retries=max_retries,
channel=channel,
description=description,
failure_rate=failure_rate,
)

if size > 1:
return self._create_graph_test_jobs(
size,
priority=priority,
max_retries=max_retries,
channel=channel,
description=description,
failure_rate=failure_rate,
)
return ""

def _create_single_test_job(
self,
priority=None,
max_retries=None,
channel=None,
description="Test job",
size=1,
failure_rate=0,
):
delayed = (
http.request.env["queue.job"]
.with_delay(
priority=priority,
max_retries=max_retries,
channel=channel,
description=description,
)
._test_job(failure_rate=failure_rate)
)
return f"job uuid: {delayed.db_record().uuid}"

TEST_GRAPH_MAX_PER_GROUP = 5

def _create_graph_test_jobs(
self,
size,
priority=None,
max_retries=None,
channel=None,
description="Test job",
failure_rate=0,
):
model = http.request.env["queue.job"]
current_count = 0

possible_grouping_methods = (chain, group)

tails = [] # we can connect new graph chains/groups to tails
root_delayable = None
while current_count < size:
jobs_count = min(
size - current_count, random.randint(1, self.TEST_GRAPH_MAX_PER_GROUP)
)

jobs = []
for __ in range(jobs_count):
current_count += 1
jobs.append(
model.delayable(
priority=priority,
max_retries=max_retries,
channel=channel,
description="%s #%d" % (description, current_count),
)._test_job(failure_rate=failure_rate)
)

grouping = random.choice(possible_grouping_methods)
delayable = grouping(*jobs)
if not root_delayable:
root_delayable = delayable
else:
tail_delayable = random.choice(tails)
tail_delayable.on_done(delayable)
tails.append(delayable)

root_delayable.delay()

return "graph uuid: {}".format(
list(root_delayable._head())[0]._generated_job.graph_uuid
)
37 changes: 37 additions & 0 deletions queue_job/data/queue_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<record id="ir_cron_queue_job_garbage_collector" model="ir.cron">
<field name="name">Jobs Garbage Collector</field>
<field name="interval_number">5</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field ref="model_queue_job" name="model_id" />
<field name="state">code</field>
<field name="code">model.requeue_stuck_jobs()</field>
</record>
<!-- Queue-job-related subtypes for messaging / Chatter -->
<record id="mt_job_failed" model="mail.message.subtype">
<field name="name">Job failed</field>
<field name="res_model">queue.job</field>
<field name="default" eval="True" />
</record>
<record id="ir_cron_autovacuum_queue_jobs" model="ir.cron">
<field name="name">AutoVacuum Job Queue</field>
<field ref="model_queue_job" name="model_id" />
<field eval="True" name="active" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field name="state">code</field>
<field name="code">model.autovacuum()</field>
</record>
</data>
<data noupdate="0">
<record model="queue.job.channel" id="channel_root">
<field name="name">root</field>
</record>
</data>
</odoo>
6 changes: 6 additions & 0 deletions queue_job/data/queue_job_function_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<odoo noupdate="1">
<record id="job_function_queue_job__test_job" model="queue.job.function">
<field name="model_id" ref="queue_job.model_queue_job" />
<field name="method">_test_job</field>
</record>
</odoo>
Loading