Repository navigation
bpo-26133: Dont unsubscribe signals in UNIX even loop on interpreter shutdown #4956
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,12 @@ def __init__(self, selector=None): | |
|
|
||
| def close(self): | ||
| super().close() | ||
| for sig in list(self._signal_handlers): | ||
| self.remove_signal_handler(sig) | ||
| if not sys.is_finalizing(): | ||
| for sig in list(self._signal_handlers): | ||
| self.remove_signal_handler(sig) | ||
| else: | ||
| warinigs.warn(f"Closing the loop {self} on interpreter shutdown " | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please replace {self} with {self!r}. See for example BaseEventLoop.close() resource warning. |
||
| f"stage, signal unsubsription is disabled") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stacklevel arg?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! :) |
||
|
|
||
| def _process_self_data(self, data): | ||
| for signum in data: | ||
|
|
||
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.
What happens if someone calls
loop.close()twice? I guessself._signal_handlers.clear()is needed.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.
Double warning will be shown obviously.
But it is very rare situation: most likely the loop will be closed by
__del__.Even
atexitcallbacks are called whensys.is_finalizing()isFalse.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.
Well, in this case I'd like to clear the list of signal handlers.
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.
Ok, will make a postfix PR soon.