Skip to content

Commit

Permalink
Merge PR #419 into 13.0
Browse files Browse the repository at this point in the history
Signed-off-by sbidoul
  • Loading branch information
OCA-git-bot committed Apr 19, 2022
2 parents a31ad13 + 42ea6c5 commit 2a7cc9c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions queue_job/jobrunner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, multi):
super(WorkerJobRunner, self).__init__(multi)
self.watchdog_timeout = None
self.runner = QueueJobRunner.from_environ_or_config()
self._recover = False

def sleep(self):
pass
Expand All @@ -64,10 +65,23 @@ def signal_handler(self, sig, frame):
self.runner.stop()

def process_work(self):
if self._recover:
_logger.info("WorkerJobRunner (%s) runner is reinitialized", self.pid)
self.runner = QueueJobRunner.from_environ_or_config()
self._recover = False
_logger.debug("WorkerJobRunner (%s) starting up", self.pid)
time.sleep(START_DELAY)
self.runner.run()

def signal_time_expired_handler(self, n, stack):
_logger.info(
"Worker (%d) CPU time limit (%s) reached.Stop gracefully and recover",
self.pid,
config["limit_time_cpu"],
)
self._recover = True
self.runner.stop()


runner_thread = None

Expand Down

0 comments on commit 2a7cc9c

Please sign in to comment.