Last active
November 13, 2018 21:20
-
-
Save josh-howes/50e53f3ad52e11b2bc85fb6964147107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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