diff --git a/trytond/trytond/application.py b/trytond/trytond/application.py index f8ba03fcf4e..d814236233a 100644 --- a/trytond/trytond/application.py +++ b/trytond/trytond/application.py @@ -32,6 +32,7 @@ from trytond.pool import Pool # noqa: E402 from trytond.wsgi import app # noqa: E402 +Pool.start_app_initialization() Pool.start() # TRYTOND_CONFIG it's managed by importing config db_names = os.environ.get('TRYTOND_DATABASE_NAMES') @@ -61,3 +62,5 @@ # # If this is not the cause, good luck application = app + +Pool.app_initialization_completed() diff --git a/trytond/trytond/cache.py b/trytond/trytond/cache.py index 5255ae30e39..96c2610ed00 100644 --- a/trytond/trytond/cache.py +++ b/trytond/trytond/cache.py @@ -370,6 +370,9 @@ def refresh_pool(cls, transaction): @classmethod def _listen(cls, dbname): + if Pool.app_initializing(): + return + current_thread = threading.current_thread() pid = os.getpid() diff --git a/trytond/trytond/pool.py b/trytond/trytond/pool.py index 760a53fc4f1..783b1f18606 100644 --- a/trytond/trytond/pool.py +++ b/trytond/trytond/pool.py @@ -50,6 +50,7 @@ class Pool(object): 'report': defaultdict(OrderedDict), } classes_mixin = defaultdict(list) + _application_initializing = False _started = False _lock = RLock() _locks = {} @@ -97,6 +98,18 @@ def register(cls, *classes, **kwargs): f"{cls} is missing metaclass {PoolMeta}") mpool[cls] = depends + @classmethod + def start_app_initialization(cls): + cls._application_initializing = True + + @classmethod + def app_initialization_completed(cls): + cls._application_initializing = False + + @classmethod + def app_initializing(cls): + return cls._application_initializing + @classmethod def add_pool_type(cls, type): cls.pool_types.add(type)