[CalendarServer-changes] [6830] CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jan 28 17:40:16 PST 2011
Revision: 6830
http://trac.macosforge.org/projects/calendarserver/changeset/6830
Author: glyph at apple.com
Date: 2011-01-28 17:40:16 -0800 (Fri, 28 Jan 2011)
Log Message:
-----------
shut down while waiting for retry
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-01-29 01:40:05 UTC (rev 6829)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/adbapi2.py 2011-01-29 01:40:16 UTC (rev 6830)
@@ -291,14 +291,18 @@
class _ConnectingPsuedoTxn(object):
- def __init__(self):
- pass
+ _retry = None
+ def __init__(self, holder):
+ self._holder = holder
def abort(self):
# not implemented yet, but let's fail rather than break the test
# raise NotImplementedError()
- pass
+ if self._retry is not None:
+ self._retry.cancel()
+ # deferred, should be returned
+ self._holder.stop()
@@ -394,7 +398,7 @@
holder = self._createHolder()
holder.start()
# FIXME: attach the holder to the txn so it can be aborted.
- txn = _ConnectingPsuedoTxn()
+ txn = _ConnectingPsuedoTxn(holder)
# take up a slot in the 'busy' list, sit there so we can be aborted.
self.busy.append(txn)
def initCursor():
@@ -421,7 +425,7 @@
# possibility of errors in submit(); TODO: test for shutdown while
# connecting.
log.err(f)
- self.reactor.callLater(self.RETRY_TIMEOUT, resubmit)
+ txn._retry = self.reactor.callLater(self.RETRY_TIMEOUT, resubmit)
def resubmit():
d = holder.submit(initCursor)
d.addCallbacks(finishInit, maybeTryAgain)
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-01-29 01:40:05 UTC (rev 6829)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py 2011-01-29 01:40:16 UTC (rev 6830)
@@ -325,3 +325,22 @@
self.assertEquals(happened, [[[1, "alpha"]]])
+ def test_shutdownDuringRetry(self):
+ """
+ If a L{ConnectionPool} is attempting to shut down while it's in the
+ process of re-trying a connection attempt that received an error, the
+ connection attempt should be cancelled and the shutdown should complete
+ as normal.
+ """
+ self.factory.defaultFail()
+ self.pool.connection()
+ errors = self.flushLoggedErrors(FakeConnectionError)
+ self.assertEquals(len(errors), 1)
+ stopd = []
+ self.pool.stopService().addBoth(stopd.append)
+ self.assertEquals([None], stopd)
+ self.assertEquals(self.clock.calls, [])
+ [holder] = self.holders
+ self.assertEquals(holder.started, True)
+ self.assertEquals(holder.stopped, True)
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110128/e5e6e944/attachment-0001.html>
More information about the calendarserver-changes
mailing list