Skip to content

Commit b84f023

Browse files
authored
Merge pull request #605 from afshin/should-run-async
Fix Handling of shell.should_run_async
2 parents 5756fe9 + 54c29d3 commit b84f023

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ipykernel/ipkernel.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,16 @@ def run_cell(*args, **kwargs):
282282
# default case: runner is asyncio and asyncio is already running
283283
# TODO: this should check every case for "are we inside the runner",
284284
# not just asyncio
285+
preprocessing_exc_tuple = None
286+
try:
287+
transformed_cell = self.shell.transform_cell(code)
288+
except Exception:
289+
transformed_cell = code
290+
preprocessing_exc_tuple = sys.exc_info()
291+
285292
if (
286293
_asyncio_runner
287-
and should_run_async(code)
294+
and should_run_async(code, transformed_cell=transformed_cell, preprocessing_exc_tuple=preprocessing_exc_tuple)
288295
and shell.loop_runner is _asyncio_runner
289296
and asyncio.get_event_loop().is_running()
290297
):
@@ -376,14 +383,14 @@ def do_complete(self, code, cursor_pos):
376383

377384
def _experimental_do_complete(self, code, cursor_pos):
378385
"""
379-
Experimental completions from IPython, using Jedi.
386+
Experimental completions from IPython, using Jedi.
380387
"""
381388
if cursor_pos is None:
382389
cursor_pos = len(code)
383390
with _provisionalcompleter():
384391
raw_completions = self.shell.Completer.completions(code, cursor_pos)
385392
completions = list(_rectify_completions(code, raw_completions))
386-
393+
387394
comps = []
388395
for comp in completions:
389396
comps.append(dict(

0 commit comments

Comments
 (0)