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


Python KernelManager.start_channels方法代码示例

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


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

示例1: km_from_string

# 需要导入模块: from IPython.kernel import KernelManager [as 别名]
# 或者: from IPython.kernel.KernelManager import start_channels [as 别名]
def km_from_string(s=''):
    """create kernel manager from IPKernelApp string
    such as '--shell=47378 --iopub=39859 --stdin=36778 --hb=52668' for IPython 0.11
    or just 'kernel-12345.json' for IPython 0.12
    """
    global km, kc, send

    from os.path import join as pjoin
    from IPython.config.loader import KeyValueConfigLoader

    try:
        from IPython.kernel import (
            KernelManager,
            find_connection_file,
        )
    except ImportError:
        from IPython.zmq.blockingkernelmanager import BlockingKernelManager as KernelManager
        from IPython.zmq.kernelapp import kernel_aliases
        from IPython.lib.kernel import find_connection_file

        s = s.replace('--existing', '')

        if '--profile' in s:
            k,p = s.split('--profile')
            k = k.lstrip().rstrip() # kernel part of the string
            p = p.lstrip().rstrip() # profile part of the string
            fullpath = find_connection_file(k,p)
        else:
            fullpath = find_connection_file(s.lstrip().rstrip())

        km = KernelManager(connection_file = fullpath)
        km.load_connection_file()
        km.start_channels()
        send = km.shell_channel.execute # not sure if this should be changed as well

        respond(None, "python.client.error.ipython-version", None)
        return


    s = s.replace('--existing', '')

    if '--profile' in s:
        k,p = s.split('--profile')
        k = k.lstrip().rstrip() # kernel part of the string
        p = p.lstrip().rstrip() # profile part of the string
        fullpath = find_connection_file(k,p)
    else:
        fullpath = find_connection_file(s.lstrip().rstrip())

    km = KernelManager(connection_file = fullpath)
    km.load_connection_file()
    kc = km.client()
    kc.start_channels()
    send = kc.execute
    return km
开发者ID:smason,项目名称:Python,代码行数:57,代码来源:ltipy.py


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