[FIX] runbot: fix tools.py

This commit is contained in:
Xavier-Do 2024-02-05 11:48:37 +01:00
parent be95c8b364
commit 7bbd1271c6

View File

@ -59,10 +59,9 @@ class RunbotClient():
try: try:
self.host.last_start_loop = fields.Datetime.now() self.host.last_start_loop = fields.Datetime.now()
self.env.cr.commit() self.env.cr.commit()
if self.env.registry != self.pool.check_signaling(): if self.env.registry != self.env.registry.check_signaling():
# the registry has changed, reload self in the new registry
self.env.reset() self.env.reset()
self.env = self.env() #not sure self.env = self.env()
self.count = self.count % self.max_count self.count = self.count % self.max_count
if self.host.paused: if self.host.paused:
sleep_time = 5 sleep_time = 5
@ -156,16 +155,15 @@ def run(client_class):
# create environment # create environment
registry = odoo.registry(args.database) registry = odoo.registry(args.database)
with odoo.api.Environment.manage(): try:
with registry.cursor() as cr: with registry.cursor() as cr:
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {}) env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
client = client_class(env) client = client_class(env)
# run main loop # run main loop
try: client.main_loop()
client.main_loop() except Exception as e:
except Exception as e: _logger.exception(str(e))
_logger.exception(str(e)) raise e
raise e
_logger.info("Stopping gracefully") _logger.info("Stopping gracefully")
def human_size(nb): def human_size(nb):