Show More
@@ -2909,8 +2909,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2909 | 2909 | return False |
|
2910 | 2910 | return _should_be_async(cell) |
|
2911 | 2911 | |
|
2912 | @asyncio.coroutine | |
|
2913 | def run_cell_async(self, raw_cell: str, store_history=False, silent=False, shell_futures=True) -> ExecutionResult: | |
|
2912 | async def run_cell_async(self, raw_cell: str, store_history=False, silent=False, shell_futures=True) -> ExecutionResult: | |
|
2914 | 2913 | """Run a complete IPython cell asynchronously. |
|
2915 | 2914 | |
|
2916 | 2915 | Parameters |
@@ -3052,7 +3051,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3052 | 3051 | if _run_async: |
|
3053 | 3052 | interactivity = 'async' |
|
3054 | 3053 | |
|
3055 |
has_raised = |
|
|
3054 | has_raised = await self.run_ast_nodes(code_ast.body, cell_name, | |
|
3056 | 3055 | interactivity=interactivity, compiler=compiler, result=result) |
|
3057 | 3056 | |
|
3058 | 3057 | self.last_execution_succeeded = not has_raised |
@@ -3132,8 +3131,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3132 | 3131 | ast.fix_missing_locations(node) |
|
3133 | 3132 | return node |
|
3134 | 3133 | |
|
3135 | @asyncio.coroutine | |
|
3136 | def run_ast_nodes(self, nodelist:ListType[AST], cell_name:str, interactivity='last_expr', | |
|
3134 | async def run_ast_nodes(self, nodelist:ListType[AST], cell_name:str, interactivity='last_expr', | |
|
3137 | 3135 | compiler=compile, result=None): |
|
3138 | 3136 | """Run a sequence of AST nodes. The execution mode depends on the |
|
3139 | 3137 | interactivity parameter. |
@@ -3218,7 +3216,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3218 | 3216 | async_wrapper_code = compiler(mod, cell_name, 'exec') |
|
3219 | 3217 | exec(async_wrapper_code, self.user_global_ns, self.user_ns) |
|
3220 | 3218 | async_code = removed_co_newlocals(self.user_ns.pop('async-def-wrapper')).__code__ |
|
3221 |
if ( |
|
|
3219 | if (await self.run_code(async_code, result, async_=True)): | |
|
3222 | 3220 | return True |
|
3223 | 3221 | else: |
|
3224 | 3222 | if sys.version_info > (3, 8): |
@@ -3245,7 +3243,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3245 | 3243 | with compiler.extra_flags(getattr(ast, 'PyCF_ALLOW_TOP_LEVEL_AWAIT', 0x0) if self.autoawait else 0x0): |
|
3246 | 3244 | code = compiler(mod, cell_name, mode) |
|
3247 | 3245 | asy = compare(code) |
|
3248 |
if ( |
|
|
3246 | if (await self.run_code(code, result, async_=asy)): | |
|
3249 | 3247 | return True |
|
3250 | 3248 | |
|
3251 | 3249 | # Flush softspace |
@@ -3284,8 +3282,7 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3284 | 3282 | |
|
3285 | 3283 | return eval(code_obj, user_ns) |
|
3286 | 3284 | |
|
3287 | @asyncio.coroutine | |
|
3288 | def run_code(self, code_obj, result=None, *, async_=False): | |
|
3285 | async def run_code(self, code_obj, result=None, *, async_=False): | |
|
3289 | 3286 | """Execute a code object. |
|
3290 | 3287 | |
|
3291 | 3288 | When an exception occurs, self.showtraceback() is called to display a |
@@ -3317,11 +3314,11 b' class InteractiveShell(SingletonConfigurable):' | |||
|
3317 | 3314 | try: |
|
3318 | 3315 | self.hooks.pre_run_code_hook() |
|
3319 | 3316 | if async_ and sys.version_info < (3,8): |
|
3320 |
last_expr = ( |
|
|
3317 | last_expr = (await self._async_exec(code_obj, self.user_ns)) | |
|
3321 | 3318 | code = compile('last_expr', 'fake', "single") |
|
3322 | 3319 | exec(code, {'last_expr': last_expr}) |
|
3323 | 3320 | elif async_ : |
|
3324 |
|
|
|
3321 | await eval(code_obj, self.user_global_ns, self.user_ns) | |
|
3325 | 3322 | else: |
|
3326 | 3323 | exec(code_obj, self.user_global_ns, self.user_ns) |
|
3327 | 3324 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now