本文整理汇总了Python中vertx.set_timer函数的典型用法代码示例。如果您正苦于以下问题:Python set_timer函数的具体用法?Python set_timer怎么用?Python set_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_timer函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_test_setup
def init_test_setup(config):
if not config.get('testmode', False):
return
def register(addr):
def _wrapper(func):
EventBus.register_handler(addr, handler=func)
return func
return _wrapper
@register('test.tweets')
def tweet_handler(msg):
print msg.body
@functools.partial(vertx.set_periodic, 1000)
def status(tid):
EventBus.publish(HBCAgent.STATUS_ADDRESS, dict(replyTo="test.status"))
@register('test.status')
def print_status(msg):
print "Status >>>", msg.body
@register('test.shutdown')
def on_shutdown(msg):
print "Shutdown >>>", msg.body
vertx.exit()
# simple shutdown hook
exit_after = config.get('testmode').get('exitAfter', 10)
if exit_after:
vertx.set_timer(exit_after * 1000,
lambda x: EventBus.publish(HBCAgent.SHUTDOWN_ADDRESS,
dict(replyTo="test.shutdown")))
示例2: start_handler
def start_handler(error, feeder):
if error:
Assert.true(False)
else:
def ack_handler(error=None):
Assert.null(error)
Test.complete()
def do_feed(timer_id):
feeder.feed({'body': 'Hello world!'}, tag='test', handler=ack_handler)
vertx.set_timer(1000, do_feed)
示例3: handler
def handler(timer_id):
tu.check_thread()
self.count += 1
if self.count == fires:
vertx.cancel_timer(timer_id)
# End test in another timer in case the first timer fires again - we want to catch that
def complete(timer_id):
tu.test_complete()
vertx.set_timer(100, complete)
elif self.count > fires:
tu.azzert(False, 'Fired too many times')
示例4: handler
def handler(msg):
if self.received:
tu.azzert(False, "handler already called")
tu.azzert(msg.body['message'] == json['message'])
EventBus.unregister_handler(id)
self.received = True
def timer_complete(id):
tu.test_complete()
# End test on a timer to give time for other messages to arrive
vertx.set_timer(100, timer_complete)
示例5: set_one_timer
def set_one_timer(time, path):
def handler(tid):
def delete_handler(err,res):
if err: print res
logger.info("file %s was deleted"% path)
fs.delete(path,handler=delete_handler)
tid = vertx.set_timer(time, handler)
示例6: test_complete_on_timer
def test_complete_on_timer():
def handler(timer_id):
VertxAssert.assertNotNull(timer_id)
VertxAssert.testComplete()
vertx.set_timer(1000, handler)
示例7: test_one_off
def test_one_off(self):
def handler(timer_id):
tu.check_thread()
tu.test_complete()
vertx.set_timer(10, handler)