Skip to content

Instantly share code, notes, and snippets.

@josh-howes
Last active Nov 13, 2018
Embed
What would you like to do?
"""
https://jupyter.readthedocs.io/en/latest/architecture/how_jupyter_ipython_work.html
http://www.tornadoweb.org/en/stable/
https://jupyter-notebook.readthedocs.io/en/stable/extending/handlers.html
"""
from IPython import get_ipython
from IPython.core.magic import register_cell_magic
from tornado import ioloop
from functools import partial
@register_cell_magic
def noblock(line, cell):
""" Jupyter Magic to run cell code asynchronously """
async_loop = ioloop.IOLoop.instance()
ipy = get_ipython()
executor = None # use default
future = async_loop.run_in_executor(executor, partial(ipy.run_cell, raw_cell=cell))
future.add_done_callback(alert_done)
def alert_done():
""" Code to execute when the cell finishes running! """
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment