From 509fa279e75975c626cd34a759c4c604e5f944f3 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 17 Apr 2020 19:15:47 +0300 Subject: [PATCH] Initialize session container with main thread session --- eos/db/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eos/db/__init__.py b/eos/db/__init__.py index e03883010..a471f83b7 100644 --- a/eos/db/__init__.py +++ b/eos/db/__init__.py @@ -66,13 +66,16 @@ gamedata_meta.bind = gamedata_engine GamedataSession = scoped_session(sessionmaker(bind=gamedata_engine, autoflush=False, expire_on_commit=False)) gamedata_session = GamedataSession() -gamedata_sessions = {} +gamedata_sessions = {threading.get_ident(): gamedata_session} + + def get_gamedata_session(): thread_id = threading.get_ident() if thread_id not in gamedata_sessions: gamedata_sessions[thread_id] = GamedataSession() return gamedata_sessions[thread_id] + pyfalog.debug('Getting gamedata version') # This should be moved elsewhere, maybe as an actual query. Current, without try-except, it breaks when making a new # game db because we haven't reached gamedata_meta.create_all()