本文整理汇总了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
示例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()