Skip to content

Instantly share code, notes, and snippets.

@fdeh75
Forked from chrisseto/await.py
Created March 18, 2019 07:13
Show Gist options
  • Save fdeh75/67d7ff8746effe1b338ebff0c4579732 to your computer and use it in GitHub Desktop.
Save fdeh75/67d7ff8746effe1b338ebff0c4579732 to your computer and use it in GitHub Desktop.
from IPython.core.magic import Magics, magics_class, line_magic
import asyncio
@magics_class
class AsyncMagics(Magics):
@line_magic
def await(self, line):
return asyncio.get_event_loop().run_until_complete(eval(line, self.shell.user_global_ns, self.shell.user_ns))
def load_ipython_extension(ipython):
ipython.register_magics(AsyncMagics)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment