Open
Description
The most surprising thing is that replicating in bash and zsh results in two different ways to get to the same exception.
Ipython has to be suspended first, using Ctrl+Z.
Bash
Bash foreground
bash-3.2$ ipython
Python 3.7.7 (default, Mar 10 2020, 15:43:03)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
[1]+ Stopped ipython
bash-3.2$ kill -2 %1
[1]+ Stopped ipython
bash-3.2$ kill -2 %1
[1]+ Stopped ipython
bash-3.2$ fg
ipython
In [1]:
KeyboardInterrupt escaped interact()
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 8, in <module>
sys.exit(start_ipython())
File "/usr/local/lib/python3.7/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/local/lib/python3.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
app.start()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 558, in mainloop
self.interact()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 541, in interact
code = self.prompt_for_code()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 469, in prompt_for_code
**self._extra_prompt_options())
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
return self.app.run(set_exception_handler=set_exception_handler)
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 812, in run
self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 614, in run_async
assert not self._is_running, "Application is already running."
AssertionError: Application is already running.
If you suspect this is an IPython 7.13.0 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
Most notably, the error did not run until I ran fg
.
Bash as a background process
This one is the most interesting because ipython is completely usable after bringing to the foreground.
bash-3.2$ ipython &
[1] 6469
bash-3.2$ Python 3.7.7 (default, Mar 10 2020, 15:43:03)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
[1]+ Stopped ipython
bash-3.2$ kill -2 %1
[1]+ Stopped ipython
bash-3.2$ kill -2 %1
[1]+ Stopped ipython
bash-3.2$ fg
ipython
KeyboardInterrupt escaped interact()
In [1]: help
Out[1]: Type help() for interactive help, or help(object) for help about object.
In [2]: exit
Zsh
Zsh without fg
On the Z shell, if I run the program, it will print the error if I run kill -2 %1
twice, regardless of whether or not I run fg
.
My-iMac% ipython
Python 3.7.7 (default, Mar 10 2020, 15:43:03)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
zsh: suspended ipython
My-iMac% kill -2 %1
My-iMac% kill -2 %1
My-iMac% In [1]:
KeyboardInterrupt escaped interact()
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 8, in <module>
sys.exit(start_ipython())
File "/usr/local/lib/python3.7/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/local/lib/python3.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
app.start()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 558, in mainloop
self.interact()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 541, in interact
code = self.prompt_for_code()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 469, in prompt_for_code
**self._extra_prompt_options())
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
return self.app.run(set_exception_handler=set_exception_handler)
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 812, in run
self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 614, in run_async
assert not self._is_running, "Application is already running."
AssertionError: Application is already running.
If you suspect this is an IPython 7.13.0 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
[1] + exit 1 ipython
Zsh with fg
If you run the kill command and then fg
, it behaves similar to bash.
My-iMac% ipython
Python 3.7.7 (default, Mar 10 2020, 15:43:03)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
zsh: suspended ipython
My-iMac% kill -2 %1
My-iMac% fg
[1] + continued ipython
^[[20;1RIn [1]:
KeyboardInterrupt escaped interact()
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 8, in <module>
sys.exit(start_ipython())
File "/usr/local/lib/python3.7/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/local/lib/python3.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
app.start()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 558, in mainloop
self.interact()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 541, in interact
code = self.prompt_for_code()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 469, in prompt_for_code
**self._extra_prompt_options())
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
return self.app.run(set_exception_handler=set_exception_handler)
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 812, in run
self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 614, in run_async
assert not self._is_running, "Application is already running."
AssertionError: Application is already running.
If you suspect this is an IPython 7.13.0 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
Zsh as a background process
When ran as a background process, zsh suspends ipython because it tries to read from the terminal, but ignores all attempts to kill. It behaves just like bash but displays another message.
My-iMac% ipython &
[1] 6416
My-iMac% Python 3.7.7 (default, Mar 10 2020, 15:43:03)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
[1] + suspended (tty output) ipython
My-iMac% kill -2 %1
My-iMac%
KeyboardInterrupt escaped interact()
kill -2 %1
My-iMac%
KeyboardInterrupt escaped interact()
kill -2 %1
My-iMac%
KeyboardInterrupt escaped interact()
kill -2 %1
My-iMac%
KeyboardInterrupt escaped interact()
kill -2 %1
My-iMac%
KeyboardInterrupt escaped interact()
kill -2 %1
My-iMac%
KeyboardInterrupt escaped interact()
fg
[1] + continued ipython
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 8, in <module>
sys.exit(start_ipython())
File "/usr/local/lib/python3.7/site-packages/IPython/__init__.py", line 126, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/local/lib/python3.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
app.start()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 558, in mainloop
self.interact()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 541, in interact
code = self.prompt_for_code()
File "/usr/local/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 469, in prompt_for_code
**self._extra_prompt_options())
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 994, in prompt
return self.app.run(set_exception_handler=set_exception_handler)
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 812, in run
self.run_async(pre_run=pre_run, set_exception_handler=set_exception_handler)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 778, in run_async
return await _run_async2()
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 760, in _run_async2
result = await _run_async()
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 682, in _run_async
with self.input.raw_mode():
File "/usr/local/lib/python3.7/site-packages/prompt_toolkit/input/vt100.py", line 259, in __enter__
termios.tcsetattr(self.fileno, termios.TCSANOW, newattr)
termios.error: (4, 'Interrupted system call')
If you suspect this is an IPython 7.13.0 bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
In summary:
- Bash
- User suspended: Will not kill until brought to foreground
- Background process: Works like normal when brought to foreground
- Zsh
- User suspended: Can either be killed by issuing the kill command twice, or by issuing the kill command than bringing to the foreground
- Background process: Will not kill until brought to foreground
Metadata
Metadata
Assignees
Labels
No labels