refactor: update server logic and adjust exercise, extra-addons files
This commit is contained in:
parent
8923642a72
commit
9b1bb0a7e1
2
exercise
2
exercise
@ -1 +1 @@
|
||||
Subproject commit 70ae66ee4b80ac134bedbe3123eebe7e973e984a
|
||||
Subproject commit f334b0a2019474ec0e031cb87cdc2ed020d8142f
|
@ -1 +1 @@
|
||||
Subproject commit 265e2490e92b945b20ddb11b9761fef5896ce518
|
||||
Subproject commit 546b2637171effc29b51dc1a13651c3014c8a67a
|
@ -448,36 +448,36 @@ class ThreadedServer(CommonServer):
|
||||
# On NOTIFY, all workers are awaken at the same time, sleeping
|
||||
# just a bit prevents they all poll the database at the exact
|
||||
# same time. This is known as the thundering herd effect.
|
||||
pass
|
||||
# from odoo.addons.base.models.ir_cron import ir_cron
|
||||
# conn = odoo.sql_db.db_connect('postgres')
|
||||
# with conn.cursor() as cr:
|
||||
# pg_conn = cr._cnx
|
||||
# # LISTEN / NOTIFY doesn't work in recovery mode
|
||||
# cr.execute("SELECT pg_is_in_recovery()")
|
||||
# in_recovery = cr.fetchone()[0]
|
||||
# if not in_recovery:
|
||||
# cr.execute("LISTEN cron_trigger")
|
||||
# else:
|
||||
# _logger.warning("PG cluster in recovery mode, cron trigger not activated")
|
||||
# cr.commit()
|
||||
|
||||
from odoo.addons.base.models.ir_cron import ir_cron
|
||||
conn = odoo.sql_db.db_connect('postgres')
|
||||
with conn.cursor() as cr:
|
||||
pg_conn = cr._cnx
|
||||
# LISTEN / NOTIFY doesn't work in recovery mode
|
||||
cr.execute("SELECT pg_is_in_recovery()")
|
||||
in_recovery = cr.fetchone()[0]
|
||||
if not in_recovery:
|
||||
cr.execute("LISTEN cron_trigger")
|
||||
else:
|
||||
_logger.warning("PG cluster in recovery mode, cron trigger not activated")
|
||||
cr.commit()
|
||||
# while True:
|
||||
# select.select([pg_conn], [], [], SLEEP_INTERVAL + number)
|
||||
# time.sleep(number / 100)
|
||||
# pg_conn.poll()
|
||||
|
||||
while True:
|
||||
select.select([pg_conn], [], [], SLEEP_INTERVAL + number)
|
||||
time.sleep(number / 100)
|
||||
pg_conn.poll()
|
||||
|
||||
registries = odoo.modules.registry.Registry.registries
|
||||
_logger.debug('cron%d polling for jobs', number)
|
||||
for db_name, registry in registries.d.items():
|
||||
if registry.ready:
|
||||
thread = threading.current_thread()
|
||||
thread.start_time = time.time()
|
||||
try:
|
||||
ir_cron._process_jobs(db_name)
|
||||
except Exception:
|
||||
_logger.warning('cron%d encountered an Exception:', number, exc_info=True)
|
||||
thread.start_time = None
|
||||
# registries = odoo.modules.registry.Registry.registries
|
||||
# _logger.debug('cron%d polling for jobs', number)
|
||||
# for db_name, registry in registries.d.items():
|
||||
# if registry.ready:
|
||||
# thread = threading.current_thread()
|
||||
# thread.start_time = time.time()
|
||||
# try:
|
||||
# ir_cron._process_jobs(db_name)
|
||||
# except Exception:
|
||||
# _logger.warning('cron%d encountered an Exception:', number, exc_info=True)
|
||||
# thread.start_time = None
|
||||
|
||||
def cron_spawn(self):
|
||||
""" Start the above runner function in a daemon thread.
|
||||
|
Loading…
Reference in New Issue
Block a user