From df480160da21779f41b94a086f4bcd5e3333a1be Mon Sep 17 00:00:00 2001 From: JanB Date: Sun, 17 Apr 2016 17:30:55 +0200 Subject: [PATCH] Handle race in database creation when running multiple WSGI instances --- cps/ub.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cps/ub.py b/cps/ub.py index b9bd76df..58e041ef 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -161,6 +161,10 @@ Session.configure(bind=engine) session = Session() if not os.path.exists(dbpath): - Base.metadata.create_all(engine) - create_default_config() - create_admin_user() + try: + Base.metadata.create_all(engine) + create_default_config() + create_admin_user() + except Exception: + pass +