本文整理汇总了Python中bokeh.server.server.Server.run_until_shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python Server.run_until_shutdown方法的具体用法?Python Server.run_until_shutdown怎么用?Python Server.run_until_shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.server.server.Server
的用法示例。
在下文中一共展示了Server.run_until_shutdown方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: invoke
# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import run_until_shutdown [as 别名]
def invoke(self, args):
'''
'''
# protect this import inside a function so that "bokeh info" can work
# even if Tornado is not installed
from bokeh.server.server import Server
log_level = getattr(logging, args.log_level.upper())
basicConfig(level=log_level, format=args.log_format)
applications = {}
_allowed_keys = ['port', 'address']
server_kwargs = { key: getattr(args, key) for key in _allowed_keys if getattr(args, key, None) is not None }
with report_server_init_errors(**server_kwargs):
server = Server(applications, **server_kwargs)
address_string = ''
if server.address is not None and server.address != '':
address_string = ' address ' + server.address
log.info("Starting Bokeh static server on port %d%s", server.port, address_string)
server.run_until_shutdown()
示例2: run_server
# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import run_until_shutdown [as 别名]
def run_server(filename, config=None, path='/', port=5000):
"""Run the bokeh server."""
if config is None:
config = default_config(filename)
makedoc = make_makedoc(filename, config)
apps = {path: Application(FunctionHandler(makedoc))}
server = Server(apps, port=port, allow_websocket_origin=['*'])
server.run_until_shutdown()
示例3: invoke
# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import run_until_shutdown [as 别名]
def invoke(self, args):
log_level = getattr(logging, args.log_level.upper())
basicConfig(level=log_level, format=args.log_format)
applications = {}
_allowed_keys = ['port', 'address']
server_kwargs = { key: getattr(args, key) for key in _allowed_keys if getattr(args, key, None) is not None }
with report_server_init_errors(**server_kwargs):
server = Server(applications, **server_kwargs)
address_string = ''
if server.address is not None and server.address != '':
address_string = ' address ' + server.address
log.info("Starting Bokeh static server on port %d%s", server.port, address_string)
server.run_until_shutdown()
示例4: invoke
# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import run_until_shutdown [as 别名]
def invoke(self, args):
'''
'''
# protect this import inside a function so that "bokeh info" can work
# even if Tornado is not installed
from bokeh.server.server import Server
argvs = { f : args.args for f in args.files}
applications = build_single_handler_applications(args.files, argvs)
log_level = getattr(logging, args.log_level.upper())
basicConfig(level=log_level, format=args.log_format, filename=args.log_file)
if len(applications) == 0:
# create an empty application by default
applications['/'] = Application()
# rename args to be compatible with Server
if args.keep_alive is not None:
args.keep_alive_milliseconds = args.keep_alive
if args.check_unused_sessions is not None:
args.check_unused_sessions_milliseconds = args.check_unused_sessions
if args.unused_session_lifetime is not None:
args.unused_session_lifetime_milliseconds = args.unused_session_lifetime
if args.stats_log_frequency is not None:
args.stats_log_frequency_milliseconds = args.stats_log_frequency
if args.mem_log_frequency is not None:
args.mem_log_frequency_milliseconds = args.mem_log_frequency
server_kwargs = { key: getattr(args, key) for key in ['port',
'address',
'allow_websocket_origin',
'num_procs',
'prefix',
'keep_alive_milliseconds',
'check_unused_sessions_milliseconds',
'unused_session_lifetime_milliseconds',
'stats_log_frequency_milliseconds',
'mem_log_frequency_milliseconds',
'use_xheaders',
'websocket_max_message_size',
]
if getattr(args, key, None) is not None }
server_kwargs['sign_sessions'] = settings.sign_sessions()
server_kwargs['secret_key'] = settings.secret_key_bytes()
server_kwargs['generate_session_ids'] = True
if args.session_ids is None:
# no --session-ids means use the env vars
pass
elif args.session_ids == 'unsigned':
server_kwargs['sign_sessions'] = False
elif args.session_ids == 'signed':
server_kwargs['sign_sessions'] = True
elif args.session_ids == 'external-signed':
server_kwargs['sign_sessions'] = True
server_kwargs['generate_session_ids'] = False
else:
raise RuntimeError("argparse should have filtered out --session-ids mode " +
args.session_ids)
if server_kwargs['sign_sessions'] and not server_kwargs['secret_key']:
die("To sign sessions, the BOKEH_SECRET_KEY environment variable must be set; " +
"the `bokeh secret` command can be used to generate a new key.")
server_kwargs['use_index'] = not args.disable_index
server_kwargs['redirect_root'] = not args.disable_index_redirect
with report_server_init_errors(**server_kwargs):
server = Server(applications, **server_kwargs)
if args.show:
# we have to defer opening in browser until we start up the server
def show_callback():
for route in applications.keys():
server.show(route)
server.io_loop.add_callback(show_callback)
address_string = 'localhost'
if server.address is not None and server.address != '':
address_string = server.address
for route in sorted(applications.keys()):
url = "http://%s:%d%s%s" % (address_string, server.port, server.prefix, route)
log.info("Bokeh app running at: %s" % url)
log.info("Starting Bokeh server with process id: %d" % getpid())
server.run_until_shutdown()
示例5: invoke
# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import run_until_shutdown [as 别名]
#.........这里部分代码省略.........
args.unused_session_lifetime_milliseconds = args.unused_session_lifetime
if args.stats_log_frequency is not None:
args.stats_log_frequency_milliseconds = args.stats_log_frequency
if args.mem_log_frequency is not None:
args.mem_log_frequency_milliseconds = args.mem_log_frequency
server_kwargs = { key: getattr(args, key) for key in ['port',
'address',
'allow_websocket_origin',
'num_procs',
'prefix',
'keep_alive_milliseconds',
'check_unused_sessions_milliseconds',
'unused_session_lifetime_milliseconds',
'stats_log_frequency_milliseconds',
'mem_log_frequency_milliseconds',
'use_xheaders',
'websocket_max_message_size',
]
if getattr(args, key, None) is not None }
server_kwargs['sign_sessions'] = settings.sign_sessions()
server_kwargs['secret_key'] = settings.secret_key_bytes()
server_kwargs['generate_session_ids'] = True
if args.session_ids is None:
# no --session-ids means use the env vars
pass
elif args.session_ids == 'unsigned':
server_kwargs['sign_sessions'] = False
elif args.session_ids == 'signed':
server_kwargs['sign_sessions'] = True
elif args.session_ids == 'external-signed':
server_kwargs['sign_sessions'] = True
server_kwargs['generate_session_ids'] = False
else:
raise RuntimeError("argparse should have filtered out --session-ids mode " +
args.session_ids)
if server_kwargs['sign_sessions'] and not server_kwargs['secret_key']:
die("To sign sessions, the BOKEH_SECRET_KEY environment variable must be set; " +
"the `bokeh secret` command can be used to generate a new key.")
server_kwargs['use_index'] = not args.disable_index
server_kwargs['redirect_root'] = not args.disable_index_redirect
server_kwargs['autoreload'] = args.dev is not None
def find_autoreload_targets(app_path):
path = os.path.abspath(app_path)
if not os.path.isdir(path):
return
for path, subdirs, files in os.walk(path):
for name in files:
if (fnmatch(name, '*.html') or
fnmatch(name, '*.css') or
fnmatch(name, '*.yaml')):
log.info("Watching: " + os.path.join(path, name))
watch(os.path.join(path, name))
def add_optional_autoreload_files(file_list):
for filen in file_list:
if os.path.isdir(filen):
log.warning("Cannot watch directory " + filen)
continue
log.info("Watching: " + filen)
watch(filen)
if server_kwargs['autoreload']:
if len(applications.keys()) != 1:
die("--dev can only support a single app.")
if server_kwargs['num_procs'] != 1:
log.info("Running in --dev mode. --num-procs is limited to 1.")
server_kwargs['num_procs'] = 1
find_autoreload_targets(args.files[0])
add_optional_autoreload_files(args.dev)
with report_server_init_errors(**server_kwargs):
server = Server(applications, **server_kwargs)
if args.show:
# we have to defer opening in browser until we start up the server
def show_callback():
for route in applications.keys():
server.show(route)
server.io_loop.add_callback(show_callback)
address_string = 'localhost'
if server.address is not None and server.address != '':
address_string = server.address
for route in sorted(applications.keys()):
url = "http://%s:%d%s%s" % (address_string, server.port, server.prefix, route)
log.info("Bokeh app running at: %s" % url)
log.info("Starting Bokeh server with process id: %d" % os.getpid())
server.run_until_shutdown()
示例6: invoke
# 需要导入模块: from bokeh.server.server import Server [as 别名]
# 或者: from bokeh.server.server.Server import run_until_shutdown [as 别名]
def invoke(self, args):
argvs = { f : args.args for f in args.files}
applications = build_single_handler_applications(args.files, argvs)
log_level = getattr(logging, args.log_level.upper())
basicConfig(level=log_level, format=args.log_format)
# This should remain here until --host is removed entirely
_fixup_deprecated_host_args(args)
if len(applications) == 0:
# create an empty application by default
applications['/'] = Application()
if args.keep_alive is not None:
if args.keep_alive == 0:
log.info("Keep-alive ping disabled")
else:
log.info("Keep-alive ping configured every %d milliseconds", args.keep_alive)
# rename to be compatible with Server
args.keep_alive_milliseconds = args.keep_alive
if args.check_unused_sessions is not None:
log.info("Check for unused sessions every %d milliseconds", args.check_unused_sessions)
# rename to be compatible with Server
args.check_unused_sessions_milliseconds = args.check_unused_sessions
if args.unused_session_lifetime is not None:
log.info("Unused sessions last for %d milliseconds", args.unused_session_lifetime)
# rename to be compatible with Server
args.unused_session_lifetime_milliseconds = args.unused_session_lifetime
if args.stats_log_frequency is not None:
log.info("Log statistics every %d milliseconds", args.stats_log_frequency)
# rename to be compatible with Server
args.stats_log_frequency_milliseconds = args.stats_log_frequency
server_kwargs = { key: getattr(args, key) for key in ['port',
'address',
'allow_websocket_origin',
'num_procs',
'prefix',
'keep_alive_milliseconds',
'check_unused_sessions_milliseconds',
'unused_session_lifetime_milliseconds',
'stats_log_frequency_milliseconds',
'use_xheaders',
]
if getattr(args, key, None) is not None }
server_kwargs['sign_sessions'] = settings.sign_sessions()
server_kwargs['secret_key'] = settings.secret_key_bytes()
server_kwargs['generate_session_ids'] = True
if args.session_ids is None:
# no --session-ids means use the env vars
pass
elif args.session_ids == 'unsigned':
server_kwargs['sign_sessions'] = False
elif args.session_ids == 'signed':
server_kwargs['sign_sessions'] = True
elif args.session_ids == 'external-signed':
server_kwargs['sign_sessions'] = True
server_kwargs['generate_session_ids'] = False
else:
raise RuntimeError("argparse should have filtered out --session-ids mode " +
args.session_ids)
if server_kwargs['sign_sessions'] and not server_kwargs['secret_key']:
die("To sign sessions, the BOKEH_SECRET_KEY environment variable must be set; " +
"the `bokeh secret` command can be used to generate a new key.")
server_kwargs['use_index'] = not args.disable_index
server_kwargs['redirect_root'] = not args.disable_index_redirect
with report_server_init_errors(**server_kwargs):
server = Server(applications, **server_kwargs)
if args.show:
# we have to defer opening in browser until we start up the server
def show_callback():
for route in applications.keys():
server.show(route)
server.io_loop.add_callback(show_callback)
address_string = ''
if server.address is not None and server.address != '':
address_string = ' address ' + server.address
log.info("Starting Bokeh server on port %d%s with applications at paths %r",
server.port,
address_string,
sorted(applications.keys()))
log.info("Starting Bokeh server with process id: %d" % getpid())
server.run_until_shutdown()