Skip to content

Commit

Permalink
Fix Handling of shell.should_run_async
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Mar 18, 2021
1 parent 5756fe9 commit 54c29d3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,16 @@ def run_cell(*args, **kwargs):
# default case: runner is asyncio and asyncio is already running
# TODO: this should check every case for "are we inside the runner",
# not just asyncio
preprocessing_exc_tuple = None
try:
transformed_cell = self.shell.transform_cell(code)
except Exception:
transformed_cell = code
preprocessing_exc_tuple = sys.exc_info()

if (
_asyncio_runner
and should_run_async(code)
and should_run_async(code, transformed_cell=transformed_cell, preprocessing_exc_tuple=preprocessing_exc_tuple)
and shell.loop_runner is _asyncio_runner
and asyncio.get_event_loop().is_running()
):
Expand Down Expand Up @@ -376,14 +383,14 @@ def do_complete(self, code, cursor_pos):

def _experimental_do_complete(self, code, cursor_pos):
"""
Experimental completions from IPython, using Jedi.
Experimental completions from IPython, using Jedi.
"""
if cursor_pos is None:
cursor_pos = len(code)
with _provisionalcompleter():
raw_completions = self.shell.Completer.completions(code, cursor_pos)
completions = list(_rectify_completions(code, raw_completions))

comps = []
for comp in completions:
comps.append(dict(
Expand Down

0 comments on commit 54c29d3

Please sign in to comment.