Skip to content

Commit ae1233a

Browse files
authored
Merge pull request #503 from OCA/18.0
Syncing from upstream OCA/queue (18.0)
2 parents 73a0f9c + a6520d9 commit ae1233a

6 files changed

Lines changed: 57 additions & 19 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ addon | version | maintainers | summary
2525
[queue_job](queue_job/) | 18.0.1.7.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
2626
[queue_job_batch](queue_job_batch/) | 18.0.1.0.0 | | Job Queue Batch
2727
[queue_job_cron](queue_job_cron/) | 18.0.1.1.1 | | Scheduled Actions as Queue Jobs
28-
[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
28+
[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
2929
[queue_job_subscribe](queue_job_subscribe/) | 18.0.1.0.0 | | Control which users are subscribed to queue job notifications
3030
[test_queue_job](test_queue_job/) | 18.0.1.0.2 | | Queue Job Tests
3131
[test_queue_job_batch](test_queue_job_batch/) | 18.0.1.0.0 | | Test Job Queue Batch

queue_job_cron_jobrunner/README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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
========================
26
Queue Job Cron Jobrunner
37
========================
@@ -7,13 +11,13 @@ Queue Job Cron Jobrunner
711
!! This file is generated by oca-gen-addon-readme !!
812
!! changes will be overwritten. !!
913
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:8805630c706cd2c715ed4e9086e130d580daff40f87890af0f3a2c928c01db16
14+
!! source digest: sha256:3c8052bb9647ac1c2222b7bbe43133884ab314534ef09686a3aef58e6b38f712
1115
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1216
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Alpha
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github

queue_job_cron_jobrunner/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Queue Job Cron Jobrunner",
33
"summary": "Run jobs without a dedicated JobRunner",
4-
"version": "18.0.1.0.0",
4+
"version": "18.0.1.0.1",
55
"development_status": "Alpha",
66
"author": "Camptocamp SA, Odoo Community Association (OCA)",
77
"maintainers": ["ivantodorovich"],

queue_job_cron_jobrunner/models/queue_job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _acquire_one_job(self):
3636
FROM queue_job
3737
WHERE state = 'pending'
3838
AND (eta IS NULL OR eta <= (now() AT TIME ZONE 'UTC'))
39-
ORDER BY date_created DESC
39+
ORDER BY priority, date_created
4040
LIMIT 1 FOR NO KEY UPDATE SKIP LOCKED
4141
"""
4242
)
@@ -55,7 +55,7 @@ def _process(self, commit=False):
5555
# while the job is processing. However, doing this will release the
5656
# lock on the db, so we need to find another way.
5757
# if commit:
58-
# self.flush()
58+
# self.env.flush_all()
5959
# self.env.cr.commit()
6060

6161
# Actual processing

queue_job_cron_jobrunner/static/description/index.html

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Queue Job Cron Jobrunner</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="queue-job-cron-jobrunner">
364-
<h1 class="title">Queue Job Cron Jobrunner</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="queue-job-cron-jobrunner">
370+
<h1>Queue Job Cron Jobrunner</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:8805630c706cd2c715ed4e9086e130d580daff40f87890af0f3a2c928c01db16
375+
!! source digest: sha256:3c8052bb9647ac1c2222b7bbe43133884ab314534ef09686a3aef58e6b38f712
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/18.0/queue_job_cron_jobrunner"><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_cron_jobrunner"><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>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/18.0/queue_job_cron_jobrunner"><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_cron_jobrunner"><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>
373378
<p>This module implements a simple <tt class="docutils literal">queue.job</tt> runner using <tt class="docutils literal">ir.cron</tt>
374379
triggers.</p>
375380
<p>It’s meant to be used on environments where the regular job runner can’t
@@ -406,7 +411,7 @@ <h1 class="title">Queue Job Cron Jobrunner</h1>
406411
</ul>
407412
</div>
408413
<div class="section" id="configuration">
409-
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
414+
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
410415
<p>Warning</p>
411416
<p>Don’t use this module if you’re already running the regular
412417
<tt class="docutils literal">queue_job</tt> runner.</p>
@@ -428,7 +433,7 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
428433
</ul>
429434
</div>
430435
<div class="section" id="known-issues-roadmap">
431-
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
436+
<h2><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h2>
432437
<ul class="simple">
433438
<li>Support channel capacity and priority. (See <tt class="docutils literal">_acquire_one_job</tt>)</li>
434439
<li>Gracefully handle CronWorker CPU timeouts. (See <tt class="docutils literal">_job_runner</tt>)</li>
@@ -437,23 +442,23 @@ <h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
437442
</ul>
438443
</div>
439444
<div class="section" id="bug-tracker">
440-
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
445+
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
441446
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/queue/issues">GitHub Issues</a>.
442447
In case of trouble, please check there if your issue has already been reported.
443448
If you spotted it first, help us to smash it by providing a detailed and welcomed
444449
<a class="reference external" href="https://github.com/OCA/queue/issues/new?body=module:%20queue_job_cron_jobrunner%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
445450
<p>Do not contact contributors directly about support or help with technical issues.</p>
446451
</div>
447452
<div class="section" id="credits">
448-
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
453+
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
449454
<div class="section" id="authors">
450-
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
455+
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
451456
<ul class="simple">
452457
<li>Camptocamp SA</li>
453458
</ul>
454459
</div>
455460
<div class="section" id="contributors">
456-
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
461+
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
457462
<ul>
458463
<li><p class="first"><a class="reference external" href="https://www.camptocamp.com">Camptocamp</a></p>
459464
<blockquote>
@@ -465,7 +470,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
465470
</ul>
466471
</div>
467472
<div class="section" id="maintainers">
468-
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
473+
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
469474
<p>This module is maintained by the OCA.</p>
470475
<a class="reference external image-reference" href="https://odoo-community.org">
471476
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -480,5 +485,6 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
480485
</div>
481486
</div>
482487
</div>
488+
</div>
483489
</body>
484490
</html>

queue_job_cron_jobrunner/tests/test_queue_job.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,33 @@ def test_queue_job_cron_trigger_enqueue_dependencies(self):
6767

6868
self.assertEqual(job_record.state, "done", "Processed OK")
6969
# if the state is "waiting_dependencies", it means the "enqueue_waiting()"
70-
# step has not been doen when the parent job has been done
70+
# step has not been done when the parent job has been done
7171
self.assertEqual(job_record_depends.state, "done", "Processed OK")
72+
73+
def test_acquire_one_job_use_priority(self):
74+
with freeze_time("2024-01-01 10:01:01"):
75+
self.env["res.partner"].with_delay(priority=3).create({"name": "test"})
76+
77+
with freeze_time("2024-01-01 10:02:01"):
78+
job = (
79+
self.env["res.partner"].with_delay(priority=1).create({"name": "test"})
80+
)
81+
82+
with freeze_time("2024-01-01 10:03:01"):
83+
self.env["res.partner"].with_delay(priority=2).create({"name": "test"})
84+
85+
self.assertEqual(self.env["queue.job"]._acquire_one_job(), job.db_record())
86+
87+
def test_acquire_one_job_consume_the_oldest_first(self):
88+
with freeze_time("2024-01-01 10:01:01"):
89+
job = (
90+
self.env["res.partner"].with_delay(priority=30).create({"name": "test"})
91+
)
92+
93+
with freeze_time("2024-01-01 10:02:01"):
94+
self.env["res.partner"].with_delay(priority=30).create({"name": "test"})
95+
96+
with freeze_time("2024-01-01 10:03:01"):
97+
self.env["res.partner"].with_delay(priority=30).create({"name": "test"})
98+
99+
self.assertEqual(self.env["queue.job"]._acquire_one_job(), job.db_record())

0 commit comments

Comments
 (0)