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
|
# On NOTIFY, all workers are awaken at the same time, sleeping
|
||||||
# just a bit prevents they all poll the database at the exact
|
# just a bit prevents they all poll the database at the exact
|
||||||
# same time. This is known as the thundering herd effect.
|
# 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
|
# while True:
|
||||||
conn = odoo.sql_db.db_connect('postgres')
|
# select.select([pg_conn], [], [], SLEEP_INTERVAL + number)
|
||||||
with conn.cursor() as cr:
|
# time.sleep(number / 100)
|
||||||
pg_conn = cr._cnx
|
# pg_conn.poll()
|
||||||
# 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:
|
# registries = odoo.modules.registry.Registry.registries
|
||||||
select.select([pg_conn], [], [], SLEEP_INTERVAL + number)
|
# _logger.debug('cron%d polling for jobs', number)
|
||||||
time.sleep(number / 100)
|
# for db_name, registry in registries.d.items():
|
||||||
pg_conn.poll()
|
# if registry.ready:
|
||||||
|
# thread = threading.current_thread()
|
||||||
registries = odoo.modules.registry.Registry.registries
|
# thread.start_time = time.time()
|
||||||
_logger.debug('cron%d polling for jobs', number)
|
# try:
|
||||||
for db_name, registry in registries.d.items():
|
# ir_cron._process_jobs(db_name)
|
||||||
if registry.ready:
|
# except Exception:
|
||||||
thread = threading.current_thread()
|
# _logger.warning('cron%d encountered an Exception:', number, exc_info=True)
|
||||||
thread.start_time = time.time()
|
# thread.start_time = None
|
||||||
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):
|
def cron_spawn(self):
|
||||||
""" Start the above runner function in a daemon thread.
|
""" Start the above runner function in a daemon thread.
|
||||||
|
Loading…
Reference in New Issue
Block a user