diff --git a/trytond/trytond/application.py b/trytond/trytond/application.py index bc10f0ebaa..0001fada77 100644 --- a/trytond/trytond/application.py +++ b/trytond/trytond/application.py @@ -31,11 +31,16 @@ Pool.start() # TRYTOND_CONFIG it's managed by importing config db_names = os.environ.get('TRYTOND_DATABASE_NAMES') 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=lambda: Pool(name).init()) + thread = threading.Thread(target=initializer, args=(name,)) thread.start() threads.append(thread) for thread in threads: diff --git a/trytond/trytond/backend/postgresql/database.py b/trytond/trytond/backend/postgresql/database.py index 27968f6940..af4b0c4759 100644 --- a/trytond/trytond/backend/postgresql/database.py +++ b/trytond/trytond/backend/postgresql/database.py @@ -286,7 +286,7 @@ class Database(DatabaseInterface): def close(self): with self._lock: logger.info('disconnection from "%s"', self.name) - self._connpool.close() + self._connpool.close(None) self._databases[os.getpid()].pop(self.name) @classmethod