Example #1
0
def cell_magic_python_module(code, **kwargs):
    """ the %%python module cell magic
    """
    kernel = get_ipython().kernel
    match = re.match(PY_MAGIC_RE, code.strip())
    groups = match.groupdict()

    with patches.ScopedCodeRunner(kernel.shell, groups["name"]):
        result = IPythonKernel.do_execute(kernel, groups["body"], **kwargs)

        if isinstance(result, Future):
            result = result.result()

        return result
Example #2
0
 def do_execute(self, code, silent, *args, **kwargs):
     self.comm.bcast(code, root=0)
     return IPythonKernel.do_execute(self, code, silent, *args, **kwargs)