`poetry run` exits on KeyboardInterrupt
See original GitHub issue- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- OS version and name: Arch Linux
- Poetry version: 0.11.4
Issue
KeyboardInterrupt is not properly handled when executing with poetry run
.
If a python script attempts to catch a KeyboardInterrupt exception, instead of it being handled, the entire poetry run ...
command exists completely.
Here is an example of running the python interpreter.
$ python
>>> try:
... while True:
... pass
... except KeyboardInterrupt:
... print('hello')
...
^Chello
>>> print('I am still in the interpreter')
poetry run python
>>> try:
... while True:
... pass
... except KeyboardInterrupt:
... print('hello')
...
^Chello
$ echo 'I am back to the shell'
Even worse is the way this affects poetry scripts. Completely exiting the script instead of handling the KeyboardInterrupt exception. pyproject.toml
[tool.poetry.scripts]
script = 'script:main'
script.py
def main():
try:
while True:
pass
except KeyboardInterrupt:
print('Never reached when executed using `poetry run script`')
$ poetry run script
^C
This does not happen when the package is installed with pip and the script is executed.
$ poetry build
$ pip install dist/project.whl
$ script
^CNever reached when executed using `poetry run script`
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:6 (4 by maintainers)
Top Results From Across the Web
`poetry run` exits on KeyboardInterrupt · Issue #393 - GitHub
I am on the latest Poetry version. I have searched the issues of this repo and believe that this is not a duplicate....
Read more >Why doesn't this Python keyboard interrupt work? (in PyCharm)
In PyCharm go to "Run"/"Edit Configurations" and check "Emulate terminal ... x == 2: doStuff() else: exit() except KeyboardInterrupt: exit().
Read more >signal — Set handlers for asynchronous events ... - Python Docs
A long-running calculation implemented purely in C (such as regular expression matching on a large body of text) may run uninterrupted for an...
Read more >Usage and Invocations — pytest documentation
Running pytest can result in six different exit codes: Exit code 0 ... It also ensures that a stack trace is printed on...
Read more >python-trio/AnyIO - Gitter
Not so far - just the one thing about CM exits not running. ... If anyio installs its own SIGINT signal handler, KeyboardInterrupt...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my experience closing tickets due to being untouched usually just means a valid ticket wasn’t addressed for a long time. I’m glad to hear that this case is an exception and that stale [bot] might go away.
Closing this issue automatically because it has not had any activity since it has been marked as stale. If you think it is still relevant and should be addressed, feel free to open a new one.