[FIX] server: avoid cron thread death

In case an exception (programming, out of memory or any other unexpected
failure), the cron_thread would crash and not recover until server restart.

Issue #15666 was an example of failure.

Courtesy of Nils Hamerlinck
This commit is contained in:
Martin Trigaux 2017-02-28 18:00:50 +01:00
parent 69e91f6a7c
commit 18fd9fe0a8
No known key found for this signature in database
GPG Key ID: 7B0E288E7C0F83A7
1 changed files with 6 additions and 2 deletions

View File

@ -262,8 +262,12 @@ class ThreadedServer(CommonServer):
_logger.debug('cron%d polling for jobs', number) _logger.debug('cron%d polling for jobs', number)
for db_name, registry in registries.iteritems(): for db_name, registry in registries.iteritems():
while registry.ready: while registry.ready:
acquired = openerp.addons.base.ir.ir_cron.ir_cron._acquire_job(db_name) try:
if not acquired: acquired = openerp.addons.base.ir.ir_cron.ir_cron._acquire_job(db_name)
if not acquired:
break
except Exception:
_logger.warning('cron%d encountered an Exception:', number, exc_info=True)
break break
def cron_spawn(self): def cron_spawn(self):