-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
cli: override default signal handlers #4190
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
Merged
gravyboat
merged 1 commit into
streamlink:master
from
bastimeyer:cli/override-default-signals
Nov 20, 2021
Merged
cli: override default signal handlers #4190
gravyboat
merged 1 commit into
streamlink:master
from
bastimeyer:cli/override-default-signals
Nov 20, 2021
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Don't raise a KeyboardInterrupt until streamlink_cli has been fully initialized. This prevents a stack call from being printed to stderr when streamlink_cli gets interrupted early. - Restore default signal handlers once streamlink_cli has finished its initialization, so that KeyboardInterrupt exceptions can be caught to perform clean up tasks. - Restore default signal handlers in test immediately after importing streamlink_cli once as early as possible, to be able to cancel the test runners regularly via a KeyboardInterrupt. - Refactor CLI logging tests, which test the log output of the initialization and need to stop execution at some point.
2886892
to
fa0b753
Compare
3 tasks
Thank you for fixing it! 👍 |
Billy2011
added a commit
to Billy2011/streamlink-27
that referenced
this pull request
Nov 21, 2021
- Don't raise a KeyboardInterrupt until streamlink_cli has been fully initialized. This prevents a stack call from being printed to stderr when streamlink_cli gets interrupted early. - Restore default signal handlers once streamlink_cli has finished its initialization, so that KeyboardInterrupt exceptions can be caught to perform clean up tasks. - Restore default signal handlers in test immediately after importing streamlink_cli once as early as possible, to be able to cancel the test runners regularly via a KeyboardInterrupt. - Refactor CLI logging tests, which test the log output of the initialization and need to stop execution at some point.
Billy2011
added a commit
to Billy2011/streamlink-27
that referenced
this pull request
Nov 21, 2021
- Don't raise a KeyboardInterrupt until streamlink_cli has been fully initialized. This prevents a stack call from being printed to stderr when streamlink_cli gets interrupted early. - Restore default signal handlers once streamlink_cli has finished its initialization, so that KeyboardInterrupt exceptions can be caught to perform clean up tasks. - Restore default signal handlers in test immediately after importing streamlink_cli once as early as possible, to be able to cancel the test runners regularly via a KeyboardInterrupt. - Refactor CLI logging tests, which test the log output of the initialization and need to stop execution at some point.
Billy2011
added a commit
to Billy2011/streamlink-27
that referenced
this pull request
Nov 21, 2021
- Don't raise a KeyboardInterrupt until streamlink_cli has been fully initialized. This prevents a stack call from being printed to stderr when streamlink_cli gets interrupted early. - Restore default signal handlers once streamlink_cli has finished its initialization, so that KeyboardInterrupt exceptions can be caught to perform clean up tasks. - Restore default signal handlers in test immediately after importing streamlink_cli once as early as possible, to be able to cancel the test runners regularly via a KeyboardInterrupt. - Refactor CLI logging tests, which test the log output of the initialization and need to stop execution at some point.
Billy2011
added a commit
to Billy2011/streamlink-27
that referenced
this pull request
Nov 22, 2021
- Don't raise a KeyboardInterrupt until streamlink_cli has been fully initialized. This prevents a stack call from being printed to stderr when streamlink_cli gets interrupted early. - Restore default signal handlers once streamlink_cli has finished its initialization, so that KeyboardInterrupt exceptions can be caught to perform clean up tasks. - Restore default signal handlers in test immediately after importing streamlink_cli once as early as possible, to be able to cancel the test runners regularly via a KeyboardInterrupt. - Refactor CLI logging tests, which test the log output of the initialization and need to stop execution at some point.
Billy2011
added a commit
to Billy2011/streamlink-27
that referenced
this pull request
Nov 22, 2021
- Don't raise a KeyboardInterrupt until streamlink_cli has been fully initialized. This prevents a stack call from being printed to stderr when streamlink_cli gets interrupted early. - Restore default signal handlers once streamlink_cli has finished its initialization, so that KeyboardInterrupt exceptions can be caught to perform clean up tasks. - Restore default signal handlers in test immediately after importing streamlink_cli once as early as possible, to be able to cancel the test runners regularly via a KeyboardInterrupt. - Refactor CLI logging tests, which test the log output of the initialization and need to stop execution at some point.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
initialized. This prevents a stack call from being printed to stderr
when streamlink_cli gets interrupted early.
initialization, so that KeyboardInterrupt exceptions can be caught to
perform clean up tasks.
streamlink_cli once as early as possible, to be able to cancel the
test runners regularly via a KeyboardInterrupt.
initialization and need to stop execution at some point.
resolves #4188
Both the regular entry script and invocation via
python -m streamlink{,_cli}
work.This does not fix a
KeyboardInterrupt
from being raised and its call stack being printed tostderr
if the user sends aSIGINT
signal to the process even before the signal override happens. The signal overrides happen as early as possible, but python has to load parts of its standard library first, so there's a small time window here where we don't have any control.There's also a secondary time window in the streamlink_cli.main.main code, as it restores the default signal handlers but then only catches KeyboardInterrupt exceptions in some cases. That shouldn't be too important though.