Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to interrupt the kernel while autocomplete is thinking crashes the runtime #10733

Closed
craigcitro opened this issue Aug 4, 2017 · 2 comments · Fixed by #10792
Closed
Milestone

Comments

@craigcitro
Copy link
Contributor

Backstory: we've added some custom completers, some of which do things that amount to making a network request (say to find out the potential arguments to a function). Sometimes, this can be slow, and users are tempted to interrupt their kernel. Doing so then crashes the kernel.

Here's a really goofy repro:

def bad_completer(*args, **kwargs):
    import time
    time.sleep(10)
    return ['houses']

get_ipython().set_hook('complete_command', bad_completer, re_key='%%file')

%%file <TAB>

and then interrupt while you're waiting.

A naive fix would be to simply catch any exception here, but I'm not sure if that should happen in a more central place.

In particular, if a user does interrupt a completer, do we want to continue with the next one, or cancel completion completely?

@Carreau Carreau added this to the 5.5 milestone Aug 4, 2017
@Carreau
Copy link
Member

Carreau commented Aug 4, 2017

Ouch, thanks, we should definitively not crash.

I'm slowly thinking on how we can make a better completer, in particular now that master is Python 3 only I have the vague plan on trying to make everything generator/coroutine. I also want to implement a kind of timeout for completer. If you have any ideas about that that they are welcome.

@chmp
Copy link

chmp commented Aug 18, 2017

A very similar issue arises on the code path for non-custom completes (see here).

Carreau added a commit to Carreau/ipython that referenced this issue Sep 12, 2017
This is likely due to completion taking too long, so just return what we
have so far, and ignore the interrupt.

closes ipython#10733
Carreau added a commit to Carreau/ipython that referenced this issue Sep 13, 2017
See ipython#10733, interruption during custom completer can crash the
kernel. Technically we should likely even protect normal completion
(like jedi taking a while), but let's get something that fix an actual
bug.

This can lead to some inconsistencies in the frontend, as you interrupt
the kernel in Command mode, and interrupting the current custom
completer will lead to normal completion being (still) returned and the
completer poping up in command mode. It's not optimal but at least we do
not loose user state.
Carreau added a commit to Carreau/ipython that referenced this issue Sep 13, 2017
See ipython#10733, interruption during custom completer can crash the
kernel. Technically we should likely even protect normal completion
(like jedi taking a while), but let's get something that fix an actual
bug.

This can lead to some inconsistencies in the frontend, as you interrupt
the kernel in Command mode, and interrupting the current custom
completer will lead to normal completion being (still) returned and the
completer poping up in command mode. It's not optimal but at least we do
not loose user state.
@Carreau Carreau modified the milestones: 5.5, 6.3 Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants