本文整理匯總了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
)