本文整理匯總了Python中buildbot.util.deferredpool.DeferredPool.notifyWhenEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Python DeferredPool.notifyWhenEmpty方法的具體用法?Python DeferredPool.notifyWhenEmpty怎麽用?Python DeferredPool.notifyWhenEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類buildbot.util.deferredpool.DeferredPool
的用法示例。
在下文中一共展示了DeferredPool.notifyWhenEmpty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_multiple_chained
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def test_multiple_chained(self):
dp = DeferredPool()
d1 = dp.notifyWhenEmpty(testImmediately=False)
self.assertNoResult(d1)
prev_deferred = defer.Deferred()
dp.add(prev_deferred)
d2 = dp.notifyWhenEmpty()
# These deferreds haven't been called yet.
for i in range(10):
self.assertNoResult(prev_deferred)
self.assertNoResult(d1)
self.assertNoResult(d2)
curr_deferred = defer.Deferred()
dp.add(curr_deferred)
prev_deferred.callback(i)
self.assertEqual(prev_deferred.result, i)
prev_deferred = curr_deferred
self.assertNoResult(prev_deferred)
self.assertNoResult(d1)
self.assertNoResult(d2)
prev_deferred.callback(10)
self.assertEqual(prev_deferred.result, 10)
# These deferreds have now been called.
self.assertEqual(d1.result, None)
self.assertEqual(d2.result, None)
示例2: testPoolWaitingCount
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testPoolWaitingCount(self):
"""
The pool must correctly report how many deferreds are waiting
for it to drain.
"""
pool = DeferredPool()
pool.notifyWhenEmpty(testImmediately=False)
pool.notifyWhenEmpty(testImmediately=False)
self.assertEqual(pool.status(), (0, 2))
示例3: testPoolStatus
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testPoolStatus(self):
"""
The pool must correctly report how many deferreds are underway
and how many are waiting for it to drain.
"""
pool = DeferredPool()
pool.add(defer.Deferred())
pool.add(defer.Deferred())
pool.notifyWhenEmpty(testImmediately=False)
self.assertEqual(pool.status(), (2, 1))
示例4: testCallbackedDeferredFiresWithTheRightResult
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testCallbackedDeferredFiresWithTheRightResult(self):
"""
The pool must correctly pass the original deferred callback result
through any callbacks it might have added.
"""
pool = DeferredPool()
d = defer.Deferred()
pool.add(d)
pool.notifyWhenEmpty()
expectedValue = object()
d.callback(expectedValue)
self.assertIdentical(d.result, expectedValue)
示例5: testErrbackedDeferredFiresWithTheRightResult
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testErrbackedDeferredFiresWithTheRightResult(self):
"""
The pool must correctly pass the original deferred errback result
through any callbacks it might have added.
"""
expectedValue = Exception()
pool = DeferredPool()
d = defer.Deferred()
pool.add(d)
pool.notifyWhenEmpty()
d.errback(expectedValue)
self.assertIdentical(d.result.value, expectedValue)
return self.assertFailure(d, Exception)
示例6: test_trivial
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def test_trivial(self):
dp = DeferredPool()
d = dp.notifyWhenEmpty()
# This should be a trival deferred
self.assertEqual(d.called, True)
self.assertEqual(d.result, None)
return d
示例7: testNotifyWhenPoolEmpties
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testNotifyWhenPoolEmpties(self):
"""
After all the deferreds in a pool fire, it should call all notify
callbacks.
"""
pool = DeferredPool()
d1 = defer.Deferred()
d2 = defer.Deferred()
d3 = defer.Deferred()
pool.add(d1)
pool.add(d2)
pool.add(d3)
# There must be 3 deferreds underway.
self.assertEqual(pool.status(), (3, 0))
wait1 = pool.notifyWhenEmpty()
wait2 = pool.notifyWhenEmpty()
# There must be 3 deferreds underway and 2 waiting.
self.assertEqual(pool.status(), (3, 2))
d1.callback(None)
d2.callback(None)
# There must be 1 deferreds underway and 2 waiting.
self.assertEqual(pool.status(), (1, 2))
# The waiters must not have fired yet.
self.assertEqual(wait1.called, False)
self.assertEqual(wait2.called, False)
d3.callback(None)
# Both waiters must have fired (with None) & the pool must be empty.
self.assertEqual(wait1.called, True)
self.assertEqual(wait2.called, True)
self.assertEqual(pool.status(), (0, 0))
self.assertEqual(wait1.result, None)
self.assertEqual(wait2.result, None)
示例8: testEmptyPoolWithTestImmediatelyFalse
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testEmptyPoolWithTestImmediatelyFalse(self):
"""
If the pool is empty and C{testImmediately} is C{False} when
calling L{notifyWhenEmpty}, the returned deferred must not have
already fired and the pool should contain one waiting deferred.
"""
pool = DeferredPool()
d = pool.notifyWhenEmpty(testImmediately=False)
self.assertEqual(d.called, False)
self.assertEqual(pool.status(), (0, 1))
示例9: testEmptyPoolWithTestImmediatelyTrue
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testEmptyPoolWithTestImmediatelyTrue(self):
"""
If the pool is empty and C{testImmediately} is C{True} when
calling L{notifyWhenEmpty}, an already fired (with C{None} result)
deferred must be returned and the pool should be empty.
"""
pool = DeferredPool()
d = pool.notifyWhenEmpty(testImmediately=True)
self.assertEqual(d.called, True)
self.assertEqual(d.result, None)
self.assertEqual(pool.status(), (0, 0))
示例10: test_reuse
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def test_reuse(self):
dp = DeferredPool()
for i in range(10):
d1 = dp.notifyWhenEmpty(testImmediately=False)
self.assertNoResult(d1)
d = defer.Deferred()
dp.add(d)
d2 = dp.notifyWhenEmpty()
# These deferreds haven't been called yet.
self.assertNoResult(d)
self.assertNoResult(d1)
self.assertNoResult(d2)
d.callback(i)
# These deferreds have now been called.
self.assertEqual(d.result, i)
self.assertEqual(d1.result, None)
self.assertEqual(d2.result, None)
示例11: testNonEmptyPoolWithTestImmediatelyTrue
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def testNonEmptyPoolWithTestImmediatelyTrue(self):
"""
If the pool is not empty and C{testImmediately} is C{True} when
calling L{notifyWhenEmpty}, the returned deferred must not have
already fired and the pool should contain one underway deferred
and one waiting.
"""
pool = DeferredPool()
pool.add(defer.Deferred())
d = pool.notifyWhenEmpty(testImmediately=True)
self.assertEqual(d.called, False)
self.assertEqual(pool.status(), (1, 1))
示例12: test_multiple
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def test_multiple(self):
dp = DeferredPool()
d1 = dp.notifyWhenEmpty(testImmediately=False)
self.assertNoResult(d1)
d_list = []
for i in range(10):
d_list.append(defer.Deferred())
dp.add(d_list[i])
d2 = dp.notifyWhenEmpty()
# These deferreds haven't been called yet.
for i, d in enumerate(d_list):
self.assertNoResult(d)
self.assertNoResult(d1)
self.assertNoResult(d2)
d.callback(i)
self.assertEqual(d.result, i)
# These deferreds have now been called.
self.assertEqual(d1.result, None)
self.assertEqual(d2.result, None)
示例13: test_simple
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def test_simple(self):
dp = DeferredPool()
d1 = dp.notifyWhenEmpty(testImmediately=False)
self.assertNoResult(d1)
deferred = defer.Deferred()
expected_value = object()
dp.add(deferred)
d2 = dp.notifyWhenEmpty()
# These deferreds haven't been called yet.
self.assertNoResult(deferred)
self.assertNoResult(d1)
self.assertNoResult(d2)
deferred.callback(expected_value)
# These deferreds have now been called.
self.assertIdentical(d1.result, None)
self.assertIdentical(d2.result, None)
self.assertIdentical(deferred.result, expected_value)
示例14: test_errback
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def test_errback(self):
dp = DeferredPool()
d1 = dp.notifyWhenEmpty(testImmediately=False)
self.assertNoResult(d1)
deferred = defer.Deferred()
expected_value = Exception('wat')
dp.add(deferred)
d2 = dp.notifyWhenEmpty()
# These deferreds haven't been called yet.
self.assertNoResult(deferred)
self.assertNoResult(d1)
self.assertNoResult(d2)
deferred.errback(expected_value)
# These deferreds have now been called.
self.assertIdentical(d1.result, None)
self.assertIdentical(d2.result, None)
self.assertFailure(deferred, Exception)
self.assertIdentical(deferred.result, expected_value)
示例15: test_trivial_not_immediately
# 需要導入模塊: from buildbot.util.deferredpool import DeferredPool [as 別名]
# 或者: from buildbot.util.deferredpool.DeferredPool import notifyWhenEmpty [as 別名]
def test_trivial_not_immediately(self):
dp = DeferredPool()
d = dp.notifyWhenEmpty(testImmediately=False)
self.assertNoResult(d)