runtime.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:rill 作者: PermaData 项目源码 文件源码
def serve_runtime(runtime=None, host=DEFAULTS['host'], port=DEFAULTS['port'],
                  registry_host=DEFAULTS['registry_host'],
                  registry_port=DEFAULTS['registry_port']):

    runtime = runtime if runtime is not None else Runtime()
    address = 'ws://{}:{:d}'.format(host, port)

    def runtime_application_task():
        """
        This greenlet runs the websocket server that responds to remote commands
        that inspect/manipulate the Runtime.
        """
        print('Runtime listening at {}'.format(address))
        WebSocketRuntimeApplication.runtimes[port] = runtime
        try:
            r = geventwebsocket.Resource(
                OrderedDict([('/', WebSocketRuntimeApplication)]))
            s = geventwebsocket.WebSocketServer(('', port), r)
            s.serve_forever()
        finally:
            WebSocketRuntimeApplication.runtimes.pop(port)

    def local_registration_task():
        """
        This greenlet will run the rill registry to register the runtime with
        the ui.
        """
        from rill.registry import serve_registry
        serve_registry(registry_host, registry_port, host, port)

    tasks = [runtime_application_task, local_registration_task]

    # Start!
    gevent.wait([gevent.spawn(t) for t in tasks])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号