Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions trytond/trytond/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -61,3 +62,5 @@
#
# If this is not the cause, good luck
application = app

Pool.app_initialization_completed()
3 changes: 3 additions & 0 deletions trytond/trytond/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
13 changes: 13 additions & 0 deletions trytond/trytond/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Pool(object):
'report': defaultdict(OrderedDict),
}
classes_mixin = defaultdict(list)
_application_initializing = False
_started = False
_lock = RLock()
_locks = {}
Expand Down Expand Up @@ -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)
Expand Down