changeset 92c0c91286a2 in trytond:5.4
details: https://hg.tryton.org/trytond?cmd=changeset;node=92c0c91286a2
description:
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
(grafted from e10be7b29deb2f25f8233ac444872f94d744edd3)
diffstat:
bin/trytond | 7 ++++++-
trytond/application.py | 7 ++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diffs (33 lines):
diff -r 41b7c23098ed -r 92c0c91286a2 bin/trytond
--- a/bin/trytond Wed Jun 03 22:13:01 2020 +0200
+++ b/bin/trytond Sat Jun 06 13:58:32 2020 +0200
@@ -31,8 +31,13 @@
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')
diff -r 41b7c23098ed -r 92c0c91286a2 trytond/application.py
--- a/trytond/application.py Wed Jun 03 22:13:01 2020 +0200
+++ b/trytond/application.py Sat Jun 06 13:58:32 2020 +0200
@@ -34,5 +34,10 @@
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()