本文整理汇总了Python中cocaine.worker.Worker.on方法的典型用法代码示例。如果您正苦于以下问题:Python Worker.on方法的具体用法?Python Worker.on怎么用?Python Worker.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocaine.worker.Worker
的用法示例。
在下文中一共展示了Worker.on方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api
# 需要导入模块: from cocaine.worker import Worker [as 别名]
# 或者: from cocaine.worker.Worker import on [as 别名]
# users
"user-exists": user_exists,
"user-signup": user_signup,
"user-signin": user_signin,
"user-remove": user_remove,
"user-list": user_list,
"user-upload": user_upload,
"user-app-list": user_apps_list,
"user-buildlog-list": user_buildlog_list,
"user-buildlog-read": user_buildlog_read,
# app
"app-info": app_info,
"app-deploy": app_deploy,
"app-start": app_start,
"app-stop": app_stop,
}
API = {"Version": 1,
"Methods": binds.keys()}
def api(request, response):
yield request.read()
response.write(API)
response.close()
if __name__ == '__main__':
W = Worker()
W.on("API", api)
W.run(binds)
示例2: main
# 需要导入模块: from cocaine.worker import Worker [as 别名]
# 或者: from cocaine.worker.Worker import on [as 别名]
def main():
w = Worker()
w.on("ping", echo)
w.run()
示例3: main
# 需要导入模块: from cocaine.worker import Worker [as 别名]
# 或者: from cocaine.worker.Worker import on [as 别名]
def main():
worker = Worker()
urlfetcher = UrlFetcher(io_loop=worker.loop)
worker.on('get', urlfetcher.on_get_request)
worker.on('post', urlfetcher.on_post_request)
worker.run()
示例4: Worker
# 需要导入模块: from cocaine.worker import Worker [as 别名]
# 或者: from cocaine.worker.Worker import on [as 别名]
#!/usr/bin/env python
import asyncio
from cocaine.worker import Worker
from cocaine.services import Service
w = Worker(app="app", uuid="a", endpoint="enp",
heartbeat_timeout=2, disown_timeout=1)
node = Service("node", version=0)
@asyncio.coroutine
def echo(request, response):
yield asyncio.sleep(1)
inp = yield request.read(timeout=1)
print inp
fut = yield node.list()
result = yield fut.get()
print result
response.write(result)
response.close()
w.on("echo", echo)
w.run()