Kernel dies when interrupting long-running completions
- Vorherrschende Sprache
- Python
- Sterne
- 734
- Forks
- 412
- Ø Merge
- 1 T. 5 Std.
- Gemergte PRs (30 T.)
- 8
Beschreibung
Under certain conditions, completion for pandas dataframes can take considerable amounts of time. When interrupting the kernel, it will die. This problem can be easily reproduced by forcing long completion times. Consider the object `inst` defined via
```python
import time
class SleepingDir(object):
def __dir__(self):
time.sleep(60)
return []
inst = SleepingDir()
```
When starting completion for `inst`, the kernel stops to respond. Interrupting the kernel kills it with the following stack trace:
```
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 434, in complete_request
matches = self.do_complete(code, cursor_pos)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 257, in do_complete
txt, matches = self.shell.complete('', line, line_cursor)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 1974, in complete
return self.Completer.complete(text, line, cursor_pos)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/completer.py", line 1840, in complete
return self._complete(line_buffer=line_buffer, cursor_pos=cursor_pos, text=text, cursor_line=0)[:2]
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/completer.py", line 1913, in _complete
cursor_pos, cursor_line, full_text)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/completer.py", line 1297, in _jedi_matches
return filter(completion_filter, interpreter.completions())
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/__init__.py", line 179, in completions
completions = completion.completions()
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/completion.py", line 96, in completions
completion_names = self._get_context_completions()
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/completion.py", line 169, in _get_context_completions
completion_names += self._trailer_completions(dot.get_previous_leaf())
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/completion.py", line 210, in _trailer_completions
completion_names += filter.values()
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/evaluate/compiled/__init__.py", line 344, in values
for name in dir(obj):
File "", line 5, in __dir__
time.sleep(60)
KeyboardInterrupt
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 434, in complete_request
matches = self.do_complete(code, cursor_pos)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 257, in do_complete
txt, matches = self.shell.complete('', line, line_cursor)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 1974, in complete
return self.Completer.complete(text, line, cursor_pos)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/completer.py", line 1840, in complete
return self._complete(line_buffer=line_buffer, cursor_pos=cursor_pos, text=text, cursor_line=0)[:2]
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/completer.py", line 1913, in _complete
cursor_pos, cursor_line, full_text)
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython/core/completer.py", line 1297, in _jedi_matches
return filter(completion_filter, interpreter.completions())
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/__init__.py", line 179, in completions
completions = completion.completions()
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/completion.py", line 96, in completions
completion_names = self._get_context_completions()
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/completion.py", line 169, in _get_context_completions
completion_names += self._trailer_completions(dot.get_previous_leaf())
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/api/completion.py", line 210, in _trailer_completions
completion_names += filter.values()
File "/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/jedi/evaluate/compiled/__init__.py", line 344, in values
for name in dir(obj):
File "", line 5, in __dir__
time.sleep(60)
KeyboardInterrupt
```
I'm running with version `4.6.1` of the `ipykernel` package. The output of `python -c "import IPython; print(IPython.sys_info())"` reads:
```
{'commit_hash': 'd86648c5d',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/Volumes/Home/venvs/py3-data-science/lib/python3.6/site-packages/IPython',
'ipython_version': '6.1.0',
'os_name': 'posix',
'platform': 'Darwin-16.7.0-x86_64-i386-64bit',
'sys_executable': '/Volumes/Home/venvs/py3-data-science/bin/python',
'sys_platform': 'darwin',
'sys_version': '3.6.1 (default, Jun 11 2017, 13:55:01) \n'
'[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]'}
```
Beitragsleitfaden
Rechercherichtung
Reproduce the failure with the SleepingDir example, then trace completion from ipykernel/kernelbase.py's complete_request through ipykernel/ipkernel.py's do_complete and the IPython/Jedi completion calls shown in the stack trace. Confirm that interrupting a slow completion no longer kills the kernel or closes its connection, and that the kernel remains usable afterward.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- jupyter, python
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100