本文整理汇总了Python中kombu.Hub.call_soon方法的典型用法代码示例。如果您正苦于以下问题:Python Hub.call_soon方法的具体用法?Python Hub.call_soon怎么用?Python Hub.call_soon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kombu.Hub
的用法示例。
在下文中一共展示了Hub.call_soon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from kombu import Hub [as 别名]
# 或者: from kombu.Hub import call_soon [as 别名]
class test_Hub:
def setup(self):
self.hub = Hub()
def teardown(self):
self.hub.close()
def test_reset(self):
self.hub.close = Mock(name='close')
self.hub._create_poller = Mock(name='_create_poller')
self.hub.reset()
self.hub.close.assert_called_with()
self.hub._create_poller.assert_called_with()
def test__close_poller__no_poller(self):
self.hub.poller = None
self.hub._close_poller()
def test__close_poller(self):
poller = self.hub.poller = Mock(name='poller')
self.hub._close_poller()
poller.close.assert_called_with()
assert self.hub.poller is None
def test_stop(self):
self.hub.call_soon = Mock(name='call_soon')
self.hub.stop()
self.hub.call_soon.assert_called_with(_raise_stop_error)
@patch('kombu.async.hub.promise')
def test_call_soon(self, promise):
callback = Mock(name='callback')
ret = self.hub.call_soon(callback, 1, 2, 3)
promise.assert_called_with(callback, (1, 2, 3))
assert promise() in self.hub._ready
assert ret is promise()
def test_call_soon__promise_argument(self):
callback = promise(Mock(name='callback'), (1, 2, 3))
ret = self.hub.call_soon(callback)
assert ret is callback
assert ret in self.hub._ready
def test_call_later(self):
callback = Mock(name='callback')
self.hub.timer = Mock(name='hub.timer')
self.hub.call_later(10.0, callback, 1, 2)
self.hub.timer.call_after.assert_called_with(10.0, callback, (1, 2))
def test_call_at(self):
callback = Mock(name='callback')
self.hub.timer = Mock(name='hub.timer')
self.hub.call_at(21231122, callback, 1, 2)
self.hub.timer.call_at.assert_called_with(21231122, callback, (1, 2))
def test_repr(self):
assert repr(self.hub)
def test_repr_flag(self):
assert repr_flag(READ) == 'R'
assert repr_flag(WRITE) == 'W'
assert repr_flag(ERR) == '!'
assert repr_flag(READ | WRITE) == 'RW'
assert repr_flag(READ | ERR) == 'R!'
assert repr_flag(WRITE | ERR) == 'W!'
assert repr_flag(READ | WRITE | ERR) == 'RW!'
def test_repr_callback_rcb(self):
def f():
pass
assert _rcb(f) == f.__name__
assert _rcb('foo') == 'foo'
@patch('kombu.async.hub.poll')
def test_start_stop(self, poll):
self.hub = Hub()
poll.assert_called_with()
poller = self.hub.poller
self.hub.stop()
self.hub.close()
poller.close.assert_called_with()
def test_fire_timers(self):
self.hub.timer = Mock()
self.hub.timer._queue = []
assert self.hub.fire_timers(
min_delay=42.324, max_delay=32.321) == 32.321
self.hub.timer._queue = [1]
self.hub.scheduler = iter([(3.743, None)])
assert self.hub.fire_timers() == 3.743
e1, e2, e3 = Mock(), Mock(), Mock()
entries = [e1, e2, e3]
def reset():
#.........这里部分代码省略.........