-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-42340: Document issues around KeyboardInterrupt #23255
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
Conversation
Update documentation to note that in some circumstances, KeyboardInterrupt may cause code to enter an inconsistent state. Also document sample workaround to avoid KeyboardInterrupt, if needed.
Doc/library/exceptions.rst
Outdated
|
||
Because it can be raised at unpredictable points, a KeyboardInterrupt | ||
may, in some circumstances, leave the running program in an inconsistent | ||
state. See :ref:`handlers-and-exceptions`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs clarification that it only applies in cases where KeyboardInterrupt
is caught. Otherwise people will become afraid to press Ctrl-C...
I'd also directly mention what to do: "... you should not try to catch KeyboardInterrupt and continue, but let it end the program as quickly as possible, or avoid raising it completely (see ...)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the pull request.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, and sorry it's been waiting for so long! I'm happy to help merge this but have a few comments.
|
||
If a signal handler raises an exception, the exception will be propagated to | ||
the main thread and may be raised after any :term:`bytecode` instruction. Most | ||
notably, a :exc:`KeyboardInterrupt` may appear at any point during execution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example in your issue (KeyboardInterrupt in the middle of an __enter__
was very helpful for me in understanding the problem. What do you think of adding it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a simple example after this paragraph.
Thanks! I'll merge this in a few days unless another core dev comes along and has concerns. |
Thanks @benfogle for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10. |
Sorry @benfogle and @JelleZijlstra, I had trouble checking out the |
GH-32184 is a backport of this pull request to the 3.9 branch. |
Thanks @benfogle for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
GH-32185 is a backport of this pull request to the 3.10 branch. |
Update documentation to note that in some circumstances, KeyboardInterrupt may cause code to enter an inconsistent state. Also document sample workaround to avoid KeyboardInterrupt, if needed. (cherry picked from commit d0906c9) Co-authored-by: benfogle <benfogle@gmail.com>
Update documentation to note that in some circumstances, KeyboardInterrupt may cause code to enter an inconsistent state. Also document sample workaround to avoid KeyboardInterrupt, if needed. (cherry picked from commit d0906c9) Co-authored-by: benfogle <benfogle@gmail.com>
Update documentation to note that in some circumstances, KeyboardInterrupt may cause code to enter an inconsistent state. Also document sample workaround to avoid KeyboardInterrupt, if needed. (cherry picked from commit d0906c9) Co-authored-by: benfogle <benfogle@gmail.com>
Update documentation to note that in some circumstances, KeyboardInterrupt may cause code to enter an inconsistent state. Also document sample workaround to avoid KeyboardInterrupt, if needed. (cherry picked from commit d0906c9) Co-authored-by: benfogle <benfogle@gmail.com>
Update documentation to note that in some circumstances,
KeyboardInterrupt may cause code to enter an inconsistent state. Also
document sample workaround to avoid KeyboardInterrupt, if needed.
https://bugs.python.org/issue42340