[CalendarServer-changes] [13597] twext/trunk/twext/enterprise
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 2 18:11:13 PDT 2014
Revision: 13597
http://trac.calendarserver.org//changeset/13597
Author: cdaboo at apple.com
Date: 2014-06-02 18:11:13 -0700 (Mon, 02 Jun 2014)
Log Message:
-----------
Remove unneeded deferreds.
Modified Paths:
--------------
twext/trunk/twext/enterprise/jobqueue.py
twext/trunk/twext/enterprise/test/test_jobqueue.py
Modified: twext/trunk/twext/enterprise/jobqueue.py
===================================================================
--- twext/trunk/twext/enterprise/jobqueue.py 2014-06-03 01:09:37 UTC (rev 13596)
+++ twext/trunk/twext/enterprise/jobqueue.py 2014-06-03 01:11:13 UTC (rev 13597)
@@ -1486,13 +1486,6 @@
-class TransactionFailed(Exception):
- """
- A transaction failed.
- """
-
-
-
def _cloneDeferred(d):
"""
Make a new Deferred, adding callbacks to C{d}.
@@ -1532,7 +1525,6 @@
self.txn = txn
self.workItemType = workItemType
self.kw = kw
- self._whenCommitted = Deferred()
self.workItem = None
@@ -1543,50 +1535,10 @@
waiting for the transaction where that addition was completed to
commit, and asking the local node controller process to do the work.
"""
- try:
- created = yield self.workItemType.makeJob(self.txn, **self.kw)
- except Exception:
- self._whenCommitted.errback(TransactionFailed)
- raise
- else:
- self.workItem = created
+ self.workItem = yield self.workItemType.makeJob(self.txn, **self.kw)
- @self.txn.postCommit
- def whenDone():
- self._whenCommitted.callback(self)
- @self.txn.postAbort
- def whenFailed():
- self._whenCommitted.errback(TransactionFailed)
-
- def whenProposed(self):
- """
- Let the caller know when the work has been proposed; i.e. when the work
- is first transmitted to the database.
-
- @return: a L{Deferred} that fires with this L{WorkProposal} when the
- relevant commands have been sent to the database to create the
- L{WorkItem}, and fails if those commands do not succeed for some
- reason.
- """
- return succeed(self)
-
-
- def whenCommitted(self):
- """
- Let the caller know when the work has been committed to; i.e. when the
- transaction where the work was proposed has been committed to the
- database.
-
- @return: a L{Deferred} that fires with this L{WorkProposal} when the
- relevant transaction has been committed, or fails if the
- transaction is not committed for any reason.
- """
- return _cloneDeferred(self._whenCommitted)
-
-
-
class _BaseQueuer(object):
implements(IQueuer)
@@ -1922,10 +1874,6 @@
"""
Register ourselves with the database and establish all outgoing
connections to other servers in the cluster.
-
- @param waitForService: an optional L{Deferred} that will be called back when
- the service startup is done.
- @type waitForService: L{Deferred} or L{None}
"""
@inlineCallbacks
def startup(txn):
Modified: twext/trunk/twext/enterprise/test/test_jobqueue.py
===================================================================
--- twext/trunk/twext/enterprise/test/test_jobqueue.py 2014-06-03 01:09:37 UTC (rev 13596)
+++ twext/trunk/twext/enterprise/test/test_jobqueue.py 2014-06-03 01:11:13 UTC (rev 13597)
@@ -39,7 +39,7 @@
from twext.enterprise.jobqueue import (
inTransaction, PeerConnectionPool, astimestamp,
LocalPerformer, _IJobPerformer, WorkItem, WorkerConnectionPool,
- ConnectionFromPeerNode, LocalQueuer,
+ ConnectionFromPeerNode,
_BaseQueuer, NonPerformingQueuer, JobItem,
WORK_PRIORITY_LOW, WORK_PRIORITY_HIGH, WORK_PRIORITY_MEDIUM,
JobDescriptor, SingletonWorkItem
@@ -360,8 +360,7 @@
notBefore=notBefore
)
- proposal = yield check
- yield proposal.whenProposed()
+ yield check
returnValue(qpool)
@@ -571,41 +570,6 @@
-class WorkProposalTests(TestCase):
- """
- Tests for L{WorkProposal}.
- """
-
- @inlineCallbacks
- def test_whenProposedSuccess(self):
- """
- The L{Deferred} returned by L{WorkProposal.whenProposed} fires when the
- SQL sent to the database has completed.
- """
- cph = SteppablePoolHelper(nodeSchema + jobSchema + schemaText)
- cph.setUp(test=self)
- lq = LocalQueuer(cph.createTransaction)
- enqTxn = cph.createTransaction()
- wp = yield lq.enqueueWork(enqTxn, DummyWorkItem, a=3, b=4)
- r = yield wp.whenProposed()
- self.assertEquals(r, wp)
-
-
- def test_whenProposedFailure(self):
- """
- The L{Deferred} returned by L{WorkProposal.whenProposed} fails with an
- errback when the SQL executed to create the WorkItem row fails.
- """
- cph = SteppablePoolHelper(nodeSchema + jobSchema + schemaText)
- cph.setUp(self)
- enqTxn = cph.createTransaction()
- lq = LocalQueuer(cph.createTransaction)
- self.failUnlessFailure(lq.enqueueWork(enqTxn, DummyWorkItem, a=3, b=4, bogus=3), TypeError)
- enqTxn.abort()
- self.flushLoggedErrors()
-
-
-
class PeerConnectionPoolUnitTests(TestCase):
"""
L{PeerConnectionPool} has many internal components.
@@ -825,8 +789,7 @@
notBefore=datetime.datetime(2012, 12, 12, 12, 12, 20)
)
- proposal = yield check
- yield proposal.whenProposed()
+ yield check
# This is going to schedule the work to happen with some asynchronous
# I/O in the middle; this is a problem because how do we know when it's
@@ -863,8 +826,7 @@
notBefore=datetime.datetime(2012, 12, 12, 12, 12, 0)
)
- proposal = yield check
- yield proposal.whenProposed()
+ yield check
clock.advance(1000)
# Advance far beyond the given timestamp.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140602/2d837425/attachment.html>
More information about the calendarserver-changes
mailing list