Skip to content
Permalink
Browse files

Merge PR #162 into 12.0

Signed-off-by sbidoul
  • Loading branch information...
OCA-git-bot committed Aug 6, 2019
2 parents 41b962b + 7e663b5 commit 4a9425ee3c9e1a1849f70e7b7736d4f651120e26
Showing with 28 additions and 11 deletions.
  1. +2 −0 queue_job/README.rst
  2. +22 −11 queue_job/jobrunner/__init__.py
  3. +2 −0 queue_job/readme/HISTORY.rst
  4. +2 −0 queue_job/static/description/index.html
@@ -209,6 +209,8 @@ Changelog
Next
~~~~

* [IMP] Dont' start the Jobrunner if root channel's capacity
is explicitly set to 0
* [ADD] Ability to set several jobs to done using an multi-action
(port of `#59 <https://github.com/OCA/queue/pull/59>`_)
* [REF] Extract a method handling the post of a message when a job is failed,
@@ -10,7 +10,7 @@
from odoo.service import server
from odoo.tools import config

from .runner import QueueJobRunner
from .runner import QueueJobRunner, _channels

_logger = logging.getLogger(__name__)

@@ -56,19 +56,34 @@ def stop(self):

runner_thread = None


def _is_runner_enabled():
return not _channels().strip().startswith('root:0')


def _start_runner_thread(server_type):
global runner_thread
if not config['stop_after_init']:
if _is_runner_enabled():
_logger.info("starting jobrunner thread (in %s)",
server_type)
runner_thread = QueueJobRunnerThread()
runner_thread.start()
else:
_logger.info("jobrunner thread (in %s) NOT started, " \
"because the root channel's capacity is set to 0",
server_type)


orig_prefork_start = server.PreforkServer.start
orig_prefork_stop = server.PreforkServer.stop
orig_threaded_start = server.ThreadedServer.start
orig_threaded_stop = server.ThreadedServer.stop


def prefork_start(server, *args, **kwargs):
global runner_thread
res = orig_prefork_start(server, *args, **kwargs)
if not config['stop_after_init']:
_logger.info("starting jobrunner thread (in prefork server)")
runner_thread = QueueJobRunnerThread()
runner_thread.start()
_start_runner_thread("prefork server")
return res


@@ -84,12 +99,8 @@ def prefork_stop(server, graceful=True):


def threaded_start(server, *args, **kwargs):
global runner_thread
res = orig_threaded_start(server, *args, **kwargs)
if not config['stop_after_init']:
_logger.info("starting jobrunner thread (in threaded server)")
runner_thread = QueueJobRunnerThread()
runner_thread.start()
_start_runner_thread("threaded server")
return res


@@ -11,6 +11,8 @@
Next
~~~~

* [IMP] Dont' start the Jobrunner if root channel's capacity
is explicitly set to 0
* [ADD] Ability to set several jobs to done using an multi-action
(port of `#59 <https://github.com/OCA/queue/pull/59>`_)
* [REF] Extract a method handling the post of a message when a job is failed,
@@ -553,6 +553,8 @@ <h1><a class="toc-backref" href="#id10">Changelog</a></h1>
<div class="section" id="next">
<h2><a class="toc-backref" href="#id11">Next</a></h2>
<ul class="simple">
<li>[IMP] Dont’ start the Jobrunner if root channel’s capacity
is explicitly set to 0</li>
<li>[ADD] Ability to set several jobs to done using an multi-action
(port of <a class="reference external" href="https://github.com/OCA/queue/pull/59">#59</a>)</li>
<li>[REF] Extract a method handling the post of a message when a job is failed,

0 comments on commit 4a9425e

Please sign in to comment.
You can’t perform that action at this time.