本文整理汇总了Python中jupyter_client.KernelManager方法的典型用法代码示例。如果您正苦于以下问题:Python jupyter_client.KernelManager方法的具体用法?Python jupyter_client.KernelManager怎么用?Python jupyter_client.KernelManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jupyter_client
的用法示例。
在下文中一共展示了jupyter_client.KernelManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_kernel
# 需要导入模块: import jupyter_client [as 别名]
# 或者: from jupyter_client import KernelManager [as 别名]
def start_kernel(self, name):
"""Start a new kernel"""
base, ext = os.path.splitext(self.parent.connection_file)
cf = '{base}-{name}{ext}'.format(
base=base,
name=name,
ext=ext,
)
manager = KernelManager(
kernel_name=name,
session=self.session,
context=self.future_context,
connection_file=cf,
)
manager.start_kernel()
self.kernels[name] = kernel = KernelProxy(
manager=manager,
shell_upstream=self.shell_stream)
self.iosub.connect(kernel.iopub_url)
return self.kernels[name]
示例2: __init__
# 需要导入模块: import jupyter_client [as 别名]
# 或者: from jupyter_client import KernelManager [as 别名]
def __init__(self, *args, **kwargs):
super(FormatManager, self).__init__(*args, **kwargs)
if self._instance is not None:
raise ValueError("FormatManager is a singleton, access with"
" FormatManager.format_manager")
self._formats = {}
self._km = KernelManager()
示例3: __init__
# 需要导入模块: import jupyter_client [as 别名]
# 或者: from jupyter_client import KernelManager [as 别名]
def __init__(
self,
timeout: int = 100,
template_type: TemplateType = TemplateType.FULL
):
"""
Initializes Exporter with default timeout (100 seconds) and template
(FULL) and handles instantiation of km and ep variables for usage when
generating NotebookNodes and their outputs.
Args:
timeout (int): Amount of time in seconds that a visualization can
run for before being stopped.
template_type (TemplateType): Type of template to use when
generating visualization output.
"""
self.timeout = timeout
self.template_type = template_type
# Create custom KernelManager.
# This will circumvent issues where kernel is shutdown after
# preprocessing. Due to the shutdown, latency would be introduced
# because a kernel must be started per visualization.
self.km = KernelManager()
self.km.start_kernel()
self.ep = ExecutePreprocessor(
timeout=self.timeout,
kernel_name='python3',
allow_errors=True
)