details: https://code.tryton.org/tryton/commit/b127dc05273e
branch: default
user: Nicolas Évrard <[email protected]>
date: Wed Sep 23 18:11:34 2026 +0200
description:
Remove useless parallelization of pool initialization
As the threads acquire the same lock from the postgres database backend
they
are in fact executed sequentially.
diffstat:
trytond/trytond/application.py | 11 ++---------
trytond/trytond/cli/__init__.py | 8 +-------
2 files changed, 3 insertions(+), 16 deletions(-)
diffs (49 lines):
diff -r 4fac5bd42fb5 -r b127dc05273e trytond/trytond/application.py
--- a/trytond/trytond/application.py Tue Sep 22 17:39:01 2026 +0200
+++ b/trytond/trytond/application.py Wed Sep 23 18:11:34 2026 +0200
@@ -33,17 +33,10 @@
if db_names:
from trytond import backend
- def initializer(name):
- Pool(name).init()
- backend.Database(name).close()
# Read with csv so database name can include special chars
reader = csv.reader(StringIO(db_names))
- threads = []
for name in next(reader):
- thread = threading.Thread(target=initializer, args=(name,))
- thread.start()
- threads.append(thread)
- for thread in threads:
- thread.join()
+ Pool(name).init()
+ backend.Database(name).close()
assert len(threads := threading.enumerate()) == 1, f"len({threads}) != 1"
diff -r 4fac5bd42fb5 -r b127dc05273e trytond/trytond/cli/__init__.py
--- a/trytond/trytond/cli/__init__.py Tue Sep 22 17:39:01 2026 +0200
+++ b/trytond/trytond/cli/__init__.py Wed Sep 23 18:11:34 2026 +0200
@@ -5,7 +5,6 @@
import glob
import logging
import os
-import threading
import trytond.commandline as commandline
import trytond.config as config
@@ -31,13 +30,8 @@
with commandline.pidfile(options):
Pool.start()
- threads = []
for name in options.database_names:
- thread = threading.Thread(target=lambda: Pool(name).init())
- thread.start()
- threads.append(thread)
- for thread in threads:
- thread.join()
+ Pool(name).init()
hostname, port = config.split_netloc(config.get('web', 'listen'))
certificate = config.get('ssl', 'certificate')
try: