self.parent.startService()
def tearDown(self):
log.msg("TestIntroducer.tearDown")
- d = defer.Deferred()
- reactor.callLater(1.1, d.callback, None)
+ d = defer.succeed(None)
d.addCallback(lambda res: self.parent.stopService())
d.addCallback(flushEventualQueue)
return d
-
def poll(self, check_f, pollinterval=0.01):
# Return a Deferred, then call check_f periodically until it returns
# True, at which point the Deferred will fire.. If check_f raises an
from twisted.trial import unittest
+from foolscap.eventual import flushEventualQueue
from allmydata import queen
q = queen.Queen()
d = q.startService()
d.addCallback(lambda res: q.stopService())
+ d.addCallback(flushEventualQueue)
return d
from twisted.web.client import getPage
class SystemTest(unittest.TestCase):
- # it takes a little while for a disconnected loopback TCP connection to
- # be noticed by the other side. This is not directly visible to us, so we
- # have to wait for time to pass rather than just waiting on a deferred.
- # This is unfortunate, both because it arbitrarily slows down the test
- # process, and because it is hard to predict what the minimum time
- # necessary would be (on a slow or heavily loaded system, 100ms might not
- # be enough).
- DISCONNECT_DELAY = 0.1
def setUp(self):
self.sparent = service.MultiService()
def tearDown(self):
log.msg("shutting down SystemTest services")
d = self.sparent.stopService()
- d.addCallback(lambda res: flushEventualQueue())
- def _done(res):
- d1 = defer.Deferred()
- reactor.callLater(self.DISCONNECT_DELAY, d1.callback, None)
- return d1
- d.addCallback(_done)
+ d.addCallback(flushEventualQueue)
return d
def add_service(self, s):
d.addCallback(_check)
def _shutdown_extra_node(res):
if self.extra_node:
- d1 = self.extra_node.stopService()
- d2 = defer.Deferred()
- reactor.callLater(self.DISCONNECT_DELAY, d2.callback, res)
- d1.addCallback(lambda ignored: d2)
- return d1
+ return self.extra_node.stopService()
return res
d.addBoth(_shutdown_extra_node)
return d