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


Python Server.stop方法代码示例

本文整理汇总了Python中bokeh.server.server.Server.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Server.stop方法的具体用法?Python Server.stop怎么用?Python Server.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.server.server.Server的用法示例。


在下文中一共展示了Server.stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ManagedServerLoop

# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import stop [as 别名]
class ManagedServerLoop(object):
    def __init__(self, application, **server_kwargs):
        loop = IOLoop()
        loop.make_current()
        server_kwargs['io_loop'] = loop
        self._server = Server(application, **server_kwargs)
    def __exit__(self, type, value, traceback):
        self._server.unlisten()
        self._server.stop()
        self._server.io_loop.close()
    def __enter__(self):
        self._server.start()
        return self._server
    @property
    def io_loop(self):
        return self.s_server.io_loop
开发者ID:jfinkels,项目名称:bokeh,代码行数:18,代码来源:utils.py

示例2: BokehServer

# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import stop [as 别名]
class BokehServer(object):
    server_kwargs = {}

    def listen(self, addr):
        if self.server:
            return
        if isinstance(addr, tuple):
            ip, port = addr
        else:
            port = addr
            ip = None
        for i in range(5):
            try:
                self.server = Server(self.apps,
                                     port=port, address=ip,
                                     check_unused_sessions_milliseconds=500,
                                     allow_websocket_origin=["*"],
                                     use_index=False,
                                     extra_patterns=[(r'/', web.RedirectHandler, {'url': '/status'})],
                                     **self.server_kwargs)
                self.server.start()

                handlers = [(self.prefix + r'/statics/(.*)',
                             web.StaticFileHandler,
                             {'path': os.path.join(os.path.dirname(__file__), 'static')})]

                self.server._tornado.add_handlers(r'.*', handlers)

                return
            except (SystemExit, EnvironmentError) as exc:
                if port != 0:
                    if ("already in use" in str(exc) or  # Unix/Mac
                            "Only one usage of" in str(exc)):  # Windows
                        msg = ("Port %d is already in use. "
                               "\nPerhaps you already have a cluster running?"
                               "\nHosting the diagnostics dashboard on a random port instead."
                               % port)
                    else:
                        msg = "Failed to start diagnostics server on port %d. " % port + str(exc)
                    warnings.warn('\n' + msg)
                    port = 0
                if i == 4:
                    raise

    @property
    def port(self):
        return (self.server.port or
                list(self.server._http._sockets.values())[0].getsockname()[1])

    def stop(self):
        for context in self.server._tornado._applications.values():
            context.run_unload_hook()

        self.server._tornado._stats_job.stop()
        self.server._tornado._cleanup_job.stop()
        if self.server._tornado._ping_job is not None:
            self.server._tornado._ping_job.stop()

        # https://github.com/bokeh/bokeh/issues/5494
        if LooseVersion(bokeh.__version__) >= '0.12.4':
            self.server.stop()
开发者ID:tomMoral,项目名称:distributed,代码行数:63,代码来源:core.py


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