Skip to content
Merged
Changes from all commits
Commits
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
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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An chance to point how and when this method will be called?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!! The function is called once the time is filled. Is preconfigured on the Worker here
https://github.com/odoo/odoo/blob/13.0/odoo/service/server.py#L967

The original value can be found here
https://github.com/odoo/odoo/blob/13.0/odoo/service/server.py#L911-L916

The CPU max time value is defined here.
https://github.com/odoo/odoo/blob/13.0/odoo/service/server.py#L948
Once this time has been reached, the error function is executed everysecond. With the original function, an exception was called

_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