[FIX] base: recover thread from down postgresql
If postgresql database is temporarly down, the cron thread may fail. The cursor creation fails when trying to connect to the server which leads to the cron thread to die (uncatched exception) and will not restart when postgres is back. Fixes #15666
This commit is contained in:
parent
48cebafdaf
commit
69e91f6a7c
|
@ -197,9 +197,9 @@ class ir_cron(osv.osv):
|
|||
"""
|
||||
db = openerp.sql_db.db_connect(db_name)
|
||||
threading.current_thread().dbname = db_name
|
||||
cr = db.cursor()
|
||||
jobs = []
|
||||
try:
|
||||
with db.cursor() as cr:
|
||||
# Make sure the database we poll has the same version as the code of base
|
||||
cr.execute("SELECT 1 FROM ir_module_module WHERE name=%s AND latest_version=%s", ('base', BASE_VERSION))
|
||||
if cr.fetchone():
|
||||
|
@ -220,8 +220,6 @@ class ir_cron(osv.osv):
|
|||
raise
|
||||
except Exception:
|
||||
_logger.warning('Exception in cron:', exc_info=True)
|
||||
finally:
|
||||
cr.close()
|
||||
|
||||
for job in jobs:
|
||||
lock_cr = db.cursor()
|
||||
|
|
Loading…
Reference in New Issue