Skip to content

Commit

Permalink
Merge pull request #426 from OCA/15.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/queue (15.0)
  • Loading branch information
bt-admin authored Dec 22, 2024
2 parents 949dcb1 + 5984ecc commit eeb15bf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 34 deletions.
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_export_async](base_export_async/) | 15.0.1.0.1 | | Asynchronous export with job queue
[queue_job](queue_job/) | 15.0.2.3.11 | [![guewen](https://github.com/guewen.png?size=30px)](https://github.com/guewen) | Job Queue
[queue_job](queue_job/) | 15.0.2.3.12 | [![guewen](https://github.com/guewen.png?size=30px)](https://github.com/guewen) | Job Queue
[queue_job_cron](queue_job_cron/) | 15.0.1.0.0 | | Scheduled Actions as Queue Jobs
[queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 15.0.2.0.0 | [![ivantodorovich](https://github.com/ivantodorovich.png?size=30px)](https://github.com/ivantodorovich) | Run jobs without a dedicated JobRunner
[queue_job_subscribe](queue_job_subscribe/) | 15.0.1.0.0 | | Control which users are subscribed to queue job notifications
Expand Down
2 changes: 1 addition & 1 deletion queue_job/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Job Queue
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c6803b0e13920b60d7c2c1b8c78a8efa67ecc1d24a4ce8ff8ec835b8b07ad987
!! source digest: sha256:273ee23baedfd996e4827a938bd5cd55a7d38f711b36e180dbd35ec55167b94b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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": "15.0.2.3.11",
"version": "15.0.2.3.12",
"author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "LGPL-3",
Expand Down
40 changes: 10 additions & 30 deletions queue_job/jobrunner/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def __contains__(self, o):
def add(self, o):
if o is None:
raise ValueError()
if o in self._removed:
self._removed.remove(o)
self._removed.discard(o)
if o in self._known:
return
self._known.add(o)
Expand All @@ -87,8 +86,7 @@ def remove(self, o):
raise ValueError()
if o not in self._known:
return
if o not in self._removed:
self._removed.add(o)
self._removed.add(o)

def pop(self):
while True:
Expand All @@ -104,24 +102,6 @@ def pop(self):
return o


class SafeSet(set):
"""A set that does not raise KeyError when removing non-existent items.
>>> s = SafeSet()
>>> s.remove(1)
>>> len(s)
0
>>> s.remove(1)
"""

def remove(self, o):
# pylint: disable=missing-return,except-pass
try:
super().remove(o)
except KeyError:
pass


@total_ordering
class ChannelJob(object):
"""A channel job is attached to a channel and holds the properties of a
Expand Down Expand Up @@ -408,8 +388,8 @@ def __init__(self, name, parent, capacity=None, sequential=False, throttle=0):
self.parent.children[name] = self
self.children = {}
self._queue = ChannelQueue()
self._running = SafeSet()
self._failed = SafeSet()
self._running = set()
self._failed = set()
self._pause_until = 0 # utc seconds since the epoch
self.capacity = capacity
self.throttle = throttle # seconds
Expand Down Expand Up @@ -463,8 +443,8 @@ def __str__(self):
def remove(self, job):
"""Remove a job from the channel."""
self._queue.remove(job)
self._running.remove(job)
self._failed.remove(job)
self._running.discard(job)
self._failed.discard(job)
if self.parent:
self.parent.remove(job)

Expand All @@ -484,8 +464,8 @@ def set_pending(self, job):
"""
if job not in self._queue:
self._queue.add(job)
self._running.remove(job)
self._failed.remove(job)
self._running.discard(job)
self._failed.discard(job)
if self.parent:
self.parent.remove(job)
_logger.debug("job %s marked pending in channel %s", job.uuid, self)
Expand All @@ -498,7 +478,7 @@ def set_running(self, job):
if job not in self._running:
self._queue.remove(job)
self._running.add(job)
self._failed.remove(job)
self._failed.discard(job)
if self.parent:
self.parent.set_running(job)
_logger.debug("job %s marked running in channel %s", job.uuid, self)
Expand All @@ -507,7 +487,7 @@ def set_failed(self, job):
"""Mark the job as failed."""
if job not in self._failed:
self._queue.remove(job)
self._running.remove(job)
self._running.discard(job)
self._failed.add(job)
if self.parent:
self.parent.remove(job)
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 @@ -367,7 +367,7 @@ <h1 class="title">Job Queue</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c6803b0e13920b60d7c2c1b8c78a8efa67ecc1d24a4ce8ff8ec835b8b07ad987
!! source digest: sha256:273ee23baedfd996e4827a938bd5cd55a7d38f711b36e180dbd35ec55167b94b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/15.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-15-0/queue-15-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=15.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

0 comments on commit eeb15bf

Please sign in to comment.