本文整理汇总了Python中txrdq.rdq.ResizableDispatchQueue.size方法的典型用法代码示例。如果您正苦于以下问题:Python ResizableDispatchQueue.size方法的具体用法?Python ResizableDispatchQueue.size怎么用?Python ResizableDispatchQueue.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txrdq.rdq.ResizableDispatchQueue
的用法示例。
在下文中一共展示了ResizableDispatchQueue.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSimplePending
# 需要导入模块: from txrdq.rdq import ResizableDispatchQueue [as 别名]
# 或者: from txrdq.rdq.ResizableDispatchQueue import size [as 别名]
def testSimplePending(self):
"""
Putting 3 jobs onto a queue with zero width should result in a
number of pending jobs of 3.
"""
dq = ResizableDispatchQueue(None)
map(dq.put, range(3))
self.assertEqual((0, 3), dq.size())
示例2: testClearQueueCancelPending
# 需要导入模块: from txrdq.rdq import ResizableDispatchQueue [as 别名]
# 或者: from txrdq.rdq.ResizableDispatchQueue import size [as 别名]
def testClearQueueCancelPending(self):
"""
When the queue is cleared with cancelPending=True, the pending jobs
should fail and receive a job whose state is CANCELLED.
"""
def ok(result):
self.fail('Unexpected success!')
def checkCancel(failure):
self.assertEqual(failure.value.state, Job.CANCELLED)
dq = ResizableDispatchQueue(None, 2)
dq.put(0).addCallbacks(ok, checkCancel)
dq.put(1).addCallbacks(ok, checkCancel)
self.assertEqual((0, 2), dq.size())
dq.clearQueue(cancelPending=True)
self.assertEqual((0, 0), dq.size())
yield dq.stop()
示例3: testSetWidthToZeroAfterInitiallyNonZero
# 需要导入模块: from txrdq.rdq import ResizableDispatchQueue [as 别名]
# 或者: from txrdq.rdq.ResizableDispatchQueue import size [as 别名]
def testSetWidthToZeroAfterInitiallyNonZero(self):
"""
Make sure that a queue whose width is initially non-zero and which
is then set to zero width does not then begin to process any added
jobs.
"""
dq = ResizableDispatchQueue(None, 3)
dq.width = 0
dq.put('aaa')
dq.put('bbb')
self.assertEqual((0, 2), dq.size())
return dq.stop()
示例4: testUnstarted
# 需要导入模块: from txrdq.rdq import ResizableDispatchQueue [as 别名]
# 或者: from txrdq.rdq.ResizableDispatchQueue import size [as 别名]
def testUnstarted(self):
"""
Check basic facts about a fresh instance of a
ResizableDispatchQueue.
"""
dq = ResizableDispatchQueue(None)
self.assertEqual(dq.pending(), [])
self.assertEqual(dq.underway(), set())
self.assertFalse(dq.stopped)
self.assertFalse(dq.paused)
self.assertEqual((0, 0), dq.size())
return dq.stop()
示例5: testClearQueue
# 需要导入模块: from txrdq.rdq import ResizableDispatchQueue [as 别名]
# 或者: from txrdq.rdq.ResizableDispatchQueue import size [as 别名]
def testClearQueue(self):
dq = ResizableDispatchQueue(None)
map(dq.put, range(3))
self.assertEqual((0, 3), dq.size())
dq.clearQueue(cancelPending=False)
self.assertEqual((0, 0), dq.size())