From 1be5fa949905f80df6a9944df95da68f71ab1b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Aug 2009 15:37:11 +0200 Subject: [PATCH] Add stop Pool and use it when dropping database --- trytond/pool.py | 15 +++++++++++++++ trytond/protocols/dispatcher.py | 1 + 2 files changed, 16 insertions(+) diff --git a/trytond/pool.py b/trytond/pool.py index fcacebf886..6d02bc0ad1 100644 --- a/trytond/pool.py +++ b/trytond/pool.py @@ -76,6 +76,21 @@ class Pool(object): finally: Pool._lock.release() + @staticmethod + def stop(database_name): + ''' + Stop the Pool + ''' + Pool._lock.acquire() + lock = Pool._locks.setdefault(database_name, RLock()) + Pool._lock.release() + lock.acquire() + if database_name in Pool._pool: + del Pool._pool[database_name] + if database_name in Pool._pools: + del Pool._pools[database_name] + lock.release() + @staticmethod def database_list(): ''' diff --git a/trytond/protocols/dispatcher.py b/trytond/protocols/dispatcher.py index 71e12ceacd..f7e6b86e58 100644 --- a/trytond/protocols/dispatcher.py +++ b/trytond/protocols/dispatcher.py @@ -239,6 +239,7 @@ def drop(database_name, password): raise else: logger.info('DROP DB: %s' % (database_name)) + Pool.stop(database_name) finally: cursor.close(close=True) return True