summaryrefslogtreecommitdiff
path: root/Mailman/database/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Mailman/database/__init__.py')
-rw-r--r--Mailman/database/__init__.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/Mailman/database/__init__.py b/Mailman/database/__init__.py
index a2b6c97ce..808ad9fd0 100644
--- a/Mailman/database/__init__.py
+++ b/Mailman/database/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 by the Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -22,12 +22,23 @@
# from Mailman import database
# database.add_list(foo)
+import os
+
def initialize():
from Mailman import database
+ from Mailman.LockFile import LockFile
+ from Mailman.configuration import config
from Mailman.database.dbcontext import dbcontext
-
- dbcontext.connect()
+ # Serialize this so we don't get multiple processes trying to create the
+ # database at the same time.
+ lockfile = os.path.join(config.LOCK_DIR, '<dbcreatelock>')
+ lock = LockFile(lockfile)
+ lock.lock()
+ try:
+ dbcontext.connect()
+ finally:
+ lock.unlock()
for attr in dir(dbcontext):
if attr.startswith('api_'):
exposed_name = attr[4:]