Skip to content

Commit d4fbedf

Browse files
committed
Initialize DB on first use, not on import (multiprocessing problems)
1 parent 84785b5 commit d4fbedf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dbutils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
@contextmanager
3030
def get_db_connection():
3131
global db_pool
32+
if db_pool is None:
33+
db_connect()
34+
3235
try:
3336
conn = db_pool.getconn()
3437
conn.autocommit = True
@@ -72,8 +75,6 @@ def db_connect():
7275
db_pool = None
7376
log.error("DB connection failed")
7477

75-
db_connect()
76-
7778
# This class is only needed until we replace all db.cursor() calls with get_db_cursor()
7879
class ThinDBWrapper(object):
7980
@staticmethod

0 commit comments

Comments
 (0)