本文整理汇总了Python中core.event_bus.EventBus.send_with_timeout方法的典型用法代码示例。如果您正苦于以下问题:Python EventBus.send_with_timeout方法的具体用法?Python EventBus.send_with_timeout怎么用?Python EventBus.send_with_timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.event_bus.EventBus
的用法示例。
在下文中一共展示了EventBus.send_with_timeout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deploy_handler
# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import send_with_timeout [as 别名]
def deploy_handler(err, id):
if err is None:
# import static_data
print "loaded " + id
def bla(reply,r2): print 'bla',reply,r2
EventBus.send_with_timeout("campudus.jsonvalidator", {
"action" : "addSchema",
"key" : "simpleAddSchema",
"jsonSchema" : {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
}, 1000, bla)
EventBus.send("campudus.jsonvalidator", {"action":"getSchemaKeys"}, bla)
else:
print 'Failed to deploy %s' % err
err.printStackTrace()
示例2: test_reply_timeout
# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import send_with_timeout [as 别名]
def test_reply_timeout(self):
json = {'message': 'hello world!'}
address = 'some-address'
reply = {'cheese': 'stilton!'}
def handler(msg):
tu.azzert(msg.body['message'] == json['message'])
id = EventBus.register_handler(address, handler=handler)
tu.azzert(id != None)
def reply_handler(error, msg):
tu.azzert(error != None)
EventBus.unregister_handler(id)
tu.test_complete()
EventBus.send_with_timeout(address, json, 10, reply_handler)