当前位置: 首页>>代码示例>>Python>>正文


Python Worker.on方法代码示例

本文整理汇总了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)
开发者ID:biinilya,项目名称:cocaine-flow,代码行数:32,代码来源:flow-tools.py

示例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()
开发者ID:antmat,项目名称:cocaine-framework-python,代码行数:6,代码来源:__init__.py

示例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()
开发者ID:lamerman,项目名称:httpclient-service,代码行数:8,代码来源:pyurlfetcher.py

示例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()
开发者ID:rmoorman,项目名称:cocaine-framework-python,代码行数:29,代码来源:w.py


注:本文中的cocaine.worker.Worker.on方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。