[CalendarServer-changes] [6862] CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 3 11:00:43 PST 2011
Revision: 6862
http://trac.macosforge.org/projects/calendarserver/changeset/6862
Author: glyph at apple.com
Date: 2011-02-03 11:00:43 -0800 (Thu, 03 Feb 2011)
Log Message:
-----------
respect stopping flag; kill pending and started-after-stop transactions.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/adbapi2.py
CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py
Modified: CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/adbapi2.py 2011-02-03 19:00:40 UTC (rev 6861)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/adbapi2.py 2011-02-03 19:00:43 UTC (rev 6862)
@@ -465,7 +465,10 @@
@return: an L{IAsyncTransaction}
"""
tracking = self._busy
- if self._free:
+ if self._stopping:
+ basetxn = FailedTxn()
+ tracking = []
+ elif self._free:
basetxn = self._free.pop(0)
else:
basetxn = SpooledTxn()
Modified: CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py 2011-02-03 19:00:40 UTC (rev 6861)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py 2011-02-03 19:00:43 UTC (rev 6862)
@@ -530,5 +530,36 @@
self.assertEquals(self.factory.connections[1].closed, True)
+ def test_connectAfterStop(self):
+ """
+ Calls to connection() after stopService() result in transactions which
+ immediately fail all operations.
+ """
+ stopResults = resultOf(self.pool.stopService())
+ self.assertEquals(stopResults, [None])
+ self.pauseHolders()
+ postClose = self.pool.connection()
+ queryResult = resultOf(postClose.execSQL("hello"))
+ self.assertEquals(len(queryResult), 1)
+ self.assertEquals(queryResult[0].type, ConnectionError)
+ def test_connectAfterStartedStopping(self):
+ """
+ Calls to connection() after stopService() has been called but before it
+ has completed will result in transactions which immediately fail all
+ operations.
+ """
+ self.pauseHolders()
+ preClose = self.pool.connection()
+ preCloseResult = resultOf(preClose.execSQL('statement'))
+ stopResult = resultOf(self.pool.stopService())
+ postClose = self.pool.connection()
+ queryResult = resultOf(postClose.execSQL("hello"))
+ self.assertEquals(stopResult, [])
+ self.assertEquals(len(queryResult), 1)
+ self.assertEquals(queryResult[0].type, ConnectionError)
+ self.assertEquals(len(preCloseResult), 1)
+ self.assertEquals(preCloseResult[0].type, ConnectionError)
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110203/cff2bac5/attachment.html>
More information about the calendarserver-changes
mailing list