From 1ad6a29546a92684f724ffdd1597476eb06998b8 2017-09-12 19:56:00 From: Matthias Bussonnier Date: 2017-09-12 19:56:00 Subject: [PATCH] Avoid crashing if interrupt the kernel during completion. This is likely due to completion taking too long, so just return what we have so far, and ignore the interrupt. closes #10733 --- diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 18905b1..ed44d98 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -1769,11 +1769,16 @@ class IPCompleter(Completer): category=ProvisionalCompleterWarning, stacklevel=2) seen = set() - for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000): - if c and (c in seen): - continue - yield c - seen.add(c) + try: + for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000): + if c and (c in seen): + continue + yield c + seen.add(c) + except KeyboardInterrupt: + """if completions take too long and users send keyboard interrupt, + do not crash and return ASAP. """ + pass def _completions(self, full_text: str, offset: int, *, _timeout)->Iterator[Completion]: """