本文整理汇总了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")))
开发者ID:ninowalker,项目名称:hosebird-driver-mod,代码行数:33,代码来源:hbdriver.py
示例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)
开发者ID:vineethvarghese,项目名称:vertigo,代码行数:11,代码来源:test_acking_feeder.py
示例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')
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:11,代码来源:test_client.py
示例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)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:12,代码来源:test_client.py
示例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)
开发者ID:jakubjosef,项目名称:Vert.x-File-Hosting,代码行数:7,代码来源:cleaner.py
示例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)
开发者ID:normanmaurer,项目名称:mod-smtpserver,代码行数:5,代码来源:basic_integration_test.py
示例7: test_one_off
def test_one_off(self):
def handler(timer_id):
tu.check_thread()
tu.test_complete()
vertx.set_timer(10, handler)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:5,代码来源:test_client.py
注:本文中的vertx.set_timer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论