[CalendarServer-changes] [11447] CalendarServer/trunk/txdav/base/datastore/subpostgres.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 1 13:03:12 PDT 2013


Revision: 11447
          http://trac.calendarserver.org//changeset/11447
Author:   sagen at apple.com
Date:     2013-07-01 13:03:12 -0700 (Mon, 01 Jul 2013)
Log Message:
-----------
Temporary: directly connect to postgres first.  Needed because ref-counting is not in place.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/base/datastore/subpostgres.py

Modified: CalendarServer/trunk/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2013-07-01 19:41:54 UTC (rev 11446)
+++ CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2013-07-01 20:03:12 UTC (rev 11447)
@@ -401,6 +401,21 @@
             createDatabaseCursor = createDatabaseConn.cursor()
             createDatabaseCursor.execute("commit")
             return createDatabaseConn, createDatabaseCursor
+            
+        try:
+            createDatabaseConn, createDatabaseCursor = createConnection()
+        except pgdb.DatabaseError:
+            # We could not connect the database, so attempt to start it
+            pass
+        except Exception, e:
+            # Some other unexpected error is preventing us from connecting
+            # to the database
+            log.warn("Failed to connect to Postgres: {e}", e=e)
+        else:
+            # Database is running, so just use our connection
+            self.ready(createDatabaseConn, createDatabaseCursor)
+            self.deactivateDelayedShutdown()
+            return
 
         monitor = _PostgresMonitor(self)
         pgCtl = self.pgCtl()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130701/dfdc140a/attachment-0001.html>


More information about the calendarserver-changes mailing list