MCPcopy Create free account
hub / github.com/ipython/ipython / _asyncify

Function _asyncify

IPython/core/async_helpers.py:78–92  ·  view source on GitHub ↗

wrap code in async def definition. And setup a bit of context to run it later.

(code: str)

Source from the content-addressed store, hash-verified

76
77
78def _asyncify(code: str) -> str:
79 """wrap code in async def definition.
80
81 And setup a bit of context to run it later.
82 """
83 res = dedent(
84 """
85 async def __wrapper__():
86 try:
87 {usercode}
88 finally:
89 locals()
90 """
91 ).format(usercode=indent(code, " " * 8))
92 return res
93
94
95class _AsyncSyntaxErrorVisitor(ast.NodeVisitor):

Callers 2

_async_parse_cellFunction · 0.85
_ast_asyncifyFunction · 0.85

Calls 3

dedentFunction · 0.85
indentFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected