Wait Pool.init threads before serving

In WSGI server that forks the main process, not waiting the end of threads
creates a dead lock.

issue9377
review311651002
This commit is contained in:
Cédric Krier committed 2020-06-06 13:58:32 +02:00
1 parent bc01b3ed99
commit cdb19908ee
2 files changed
+12 -2

No files matched your search

+6 -1
View File
@@ -31,8 +31,13 @@ from trytond.pool import Pool
from trytond.modules import get_module_list, get_module_info
with commandline.pidfile(options):
threads = []
for name in options.database_names:
threading.Thread(target=Pool(name).init).start()
thread = threading.Thread(target=Pool(name).init)
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
hostname, port = split_netloc(config.get('web', 'listen'))
certificate = config.get('ssl', 'certificate')
privatekey = config.get('ssl', 'privatekey')
+6 -1
View File
@@ -34,5 +34,10 @@ db_names = os.environ.get('TRYTOND_DATABASE_NAMES')
if db_names:
# Read with csv so database name can include special chars
reader = csv.reader(StringIO(db_names))
threads = []
for name in next(reader):
threading.Thread(target=Pool(name).init).start()
thread = threading.Thread(target=Pool(name).init)
thread.start()
threads.append(thread)
for thread in threads:
thread.join()