本文整理汇总了Python中Timer.enter_at方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.enter_at方法的具体用法?Python Timer.enter_at怎么用?Python Timer.enter_at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer.enter_at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_handle_error
# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import enter_at [as 别名]
def test_handle_error(self):
from datetime import datetime
on_error = Mock(name='on_error')
s = Timer(on_error=on_error)
with patch('kombu.async.timer.to_timestamp') as tot:
tot.side_effect = OverflowError()
s.enter_at(Entry(lambda: None, (), {}),
eta=datetime.now())
s.enter_at(Entry(lambda: None, (), {}), eta=None)
s.on_error = None
with pytest.raises(OverflowError):
s.enter_at(Entry(lambda: None, (), {}),
eta=datetime.now())
on_error.assert_called_once()
exc = on_error.call_args[0][0]
assert isinstance(exc, OverflowError)
示例2: test_handle_error
# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import enter_at [as 别名]
def test_handle_error(self):
from datetime import datetime
scratch = [None]
def on_error(exc_info):
scratch[0] = exc_info
s = Timer(on_error=on_error)
with patch("kombu.async.timer.to_timestamp") as tot:
tot.side_effect = OverflowError()
s.enter_at(Entry(lambda: None, (), {}), eta=datetime.now())
s.enter_at(Entry(lambda: None, (), {}), eta=None)
s.on_error = None
with self.assertRaises(OverflowError):
s.enter_at(Entry(lambda: None, (), {}), eta=datetime.now())
exc = scratch[0]
self.assertIsInstance(exc, OverflowError)