[CalendarServer-changes] [6863] CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 3 11:00:46 PST 2011
Revision: 6863
http://trac.macosforge.org/projects/calendarserver/changeset/6863
Author: glyph at apple.com
Date: 2011-02-03 11:00:46 -0800 (Thu, 03 Feb 2011)
Log Message:
-----------
Renaming for clarity: BaseSqlTxn -> _ConnectedTxn
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:43 UTC (rev 6862)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/adbapi2.py 2011-02-03 19:00:46 UTC (rev 6863)
@@ -62,7 +62,7 @@
DEFAULT_PARAM_STYLE = 'pyformat'
-class BaseSqlTxn(object):
+class _ConnectedTxn(object):
"""
L{IAsyncTransaction} implementation based on a L{ThreadHolder} in the
current process.
@@ -193,7 +193,7 @@
"""
A L{SpooledTxn} is an implementation of L{IAsyncTransaction} which cannot
yet actually execute anything, so it spools SQL reqeusts for later
- execution. When a L{BaseSqlTxn} becomes available later, it can be
+ execution. When a L{_ConnectedTxn} becomes available later, it can be
unspooled onto that.
"""
@@ -257,10 +257,11 @@
class PooledSqlTxn(proxyForInterface(iface=IAsyncTransaction,
originalAttribute='_baseTxn')):
"""
- This is a temporary throw-away wrapper for the longer-lived BaseSqlTxn, so
- that if a badly-behaved API client accidentally hangs on to one of these
- and, for example C{.abort()}s it multiple times once another client is
- using that connection, it will get some harmless tracebacks.
+ This is a temporary throw-away wrapper for the longer-lived
+ L{_ConnectedTxn}, so that if a badly-behaved API client accidentally hangs
+ on to one of these and, for example C{.abort()}s it multiple times once
+ another client is using that connection, it will get some harmless
+ tracebacks.
"""
def __init__(self, pool, baseTxn):
@@ -278,7 +279,9 @@
def _unspoolOnto(self, baseTxn):
"""
- Replace my C{_baseTxn}, currently a L{SpooledTxn}, with a L{BaseSqlTxn}.
+ Replace my C{_baseTxn}, currently a L{SpooledTxn}, with a new
+ implementation of L{IAsyncTransaction} that will actually do the work;
+ either a L{_ConnectedTxn} or a L{FailedTxn}.
"""
spooledBase = self._baseTxn
self._baseTxn = baseTxn
@@ -368,11 +371,11 @@
@type reactor: L{IReactorTime} and L{IReactorThreads} provider.
- @ivar _free: The list of free L{BaseSqlTxn} objects which are not currently
- attached to a L{PooledSqlTxn} object, and have active connections ready
- for processing a new transaction.
+ @ivar _free: The list of free L{_ConnectedTxn} objects which are not
+ currently attached to a L{PooledSqlTxn} object, and have active
+ connections ready for processing a new transaction.
- @ivar _busy: The list of busy L{BaseSqlTxn} objects; those currently
+ @ivar _busy: The list of busy L{_ConnectedTxn} objects; those currently
servicing an unfinished L{PooledSqlTxn} object.
@ivar _finishing: The list of 2-tuples of L{PooledSqlTxn} objects which have
@@ -441,9 +444,9 @@
# 'abort()' will have put them there. Shut down all the associated
# ThreadHolders.
while self._free:
- # (Stopping a BaseSqlTxn doesn't automatically recycle it / remove
- # it the way aborting a PooledSqlTxn does, so we need to .pop()
- # here.)
+ # (Stopping a _ConnectedTxn doesn't automatically recycle it /
+ # remove it the way aborting a PooledSqlTxn does, so we need to
+ # .pop() here.)
free = self._free.pop()
# stop() really shouldn't be able to fail, as it's just stopping the
# thread, and the holder's stop() is independently submitted.
@@ -484,7 +487,7 @@
def _startOneMore(self):
"""
- Start one more BaseSqlTxn.
+ Start one more _ConnectedTxn.
"""
holder = self._createHolder()
holder.start()
@@ -498,7 +501,7 @@
cursor = connection.cursor()
return (connection, cursor)
def finishInit((connection, cursor)):
- baseTxn = BaseSqlTxn(
+ baseTxn = _ConnectedTxn(
pool=self,
threadHolder=holder,
connection=connection,
@@ -517,7 +520,8 @@
def _repoolAfter(self, txn, d):
"""
- Re-pool the given L{BaseSqlTxn} after the given L{Deferred} has fired.
+ Re-pool the given L{_ConnectedTxn} after the given L{Deferred} has
+ fired.
"""
self._busy.remove(txn)
finishRecord = (txn, d)
@@ -531,7 +535,7 @@
def _repoolNow(self, txn):
"""
- Recycle a L{BaseSqlTxn} into the free list.
+ Recycle a L{_ConnectedTxn} into the free list.
"""
txn.reset()
if self._waiting:
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:43 UTC (rev 6862)
+++ CalendarServer/branches/users/glyph/db-reconnect/twext/enterprise/test/test_adbapi2.py 2011-02-03 19:00:46 UTC (rev 6863)
@@ -320,9 +320,9 @@
"""
When the number of outstanding busy transactions exceeds the number of
slots specified by L{ConnectionPool.maxConnections},
- L{ConnectionPool.connection} will return a L{PooledSqlTxn} that is not
- backed by any L{BaseSqlTxn}; this object will queue its SQL statements
- until an existing connection becomes available.
+ L{ConnectionPool.connection} will return a pooled transaction that is
+ not backed by any real database connection; this object will queue its
+ SQL statements until an existing connection becomes available.
"""
a = self.pool.connection()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110203/24412844/attachment-0001.html>
More information about the calendarserver-changes
mailing list