GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-26133: Dont unsubscribe signals in UNIX even loop on interpreter shutdown by asvetlov · Pull Request #4956 · python/cpython Conversation
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.remove_signal_handler(sig) | ||
| else: | ||
| warinigs.warn(f"Closing the loop {self} on interpreter shutdown " | ||
| f"stage, signal unsubsription is disabled") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
stacklevel arg?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sure! :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| else: | ||
| warinigs.warn(f"Closing the loop {self} on interpreter shutdown " | ||
| f"stage, signal unsubsription is disabled", | ||
| stacklevel=2) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that stacklevel=2 is correct. Maybe remove it?
For the warning category, I hesitate to use ResourceWarning and pass source=self. ResourceWarning are quiet by default. It's maybe better to not pollute stdout with such warning?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| for sig in list(self._signal_handlers): | ||
| self.remove_signal_handler(sig) | ||
| else: | ||
| warinigs.warn(f"Closing the loop {self} on interpreter shutdown " |
There was a problem hiding this comment.
The 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1 @@ | |||
| Dont unsubscribe signals in asyncio UNIX event loop on interpreter shutdown. | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It should be written "Don't", no?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Notes are fixed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| else: | ||
| warinigs.warn(f"Closing the loop {self!r} on interpreter shutdown " | ||
| f"stage, signal unsubsription is disabled", | ||
| ResourceWarning) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For ResourceWarning, you can add source=self, so the warning will be logged with the traceback were the event loop was created, if traceback is enabled.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
It's hackish, but as I explained at https://bugs.python.org/issue26133#msg258429 it's hard to fix the root issue.
The hack is only used when the code doesn't explicitly close the event loop, which is a bug on itself. So it's ok to workaround https://bugs.python.org/issue26133 side effect.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @asvetlov for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-4962 is a backport of this pull request to the 3.6 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…shutdown (pythonGH-4956) (cherry picked from commit 4a02543)
| super().close() | ||
| for sig in list(self._signal_handlers): | ||
| self.remove_signal_handler(sig) | ||
| if not sys.is_finalizing(): |
There was a problem 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 guess self._signal_handlers.clear() is needed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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 atexit callbacks are called when sys.is_finalizing() is False.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok, will make a postfix PR soon.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
And what's the point of showing 'close()' explicitly? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'd appreciate if patches like this are merged with my approval. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@1st1 sorry |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
NP, Andrew, it's not a big deal. I trust you and Victor completely. It's just that I have a few follow-up questions that I wish we discussed before the merge just in case. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Stack trace points in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.