Uh oh!
There was an error while loading. Please reload this page.
Fix remove_signal_handler to not to crash after PyOS_FiniInterrupts - #456
Fix remove_signal_handler to not to crash after PyOS_FiniInterrupts#4561st1 wants to merge 2 commits into
Conversation
| if self._interpreter_shutting_down: | ||
| # The interpreter is being shutdown. `PyOS_FiniInterrupts` | ||
| # was already called and it has restored all signals already. | ||
| return |
There was a problem hiding this comment.
Instead of just return, we can emit a warning that the loop wasn't properly closed. @gvanrossum what do you think about that?
There was a problem hiding this comment.
Only in debug mode. But frankly I don't understand this code.
| if self._interpreter_shutting_down: | ||
| # The interpreter is being shutdown. `PyOS_FiniInterrupts` | ||
| # was already called and it has restored all signals already. | ||
| return |
gvanrossum
left a comment
There was a problem hiding this comment.
I don't understand all this well enough to know whether this is a good idea or not. We really need to find someone else who wants to co-own asyncio -- ATM I feel my role is mostly that of giving you permission to commit what you see fit and I am not actually comfortable with this -- we'll end up with there being only one person who understands asyncio and that's not enough for such an important stdlib module.
| if self._interpreter_shutting_down: | ||
| # The interpreter is being shutdown. `PyOS_FiniInterrupts` | ||
| # was already called and it has restored all signals already. | ||
| return |
There was a problem hiding this comment.
Only in debug mode. But frankly I don't understand this code.
gvanrossum
commented
Nov 7, 2016
via email
Do we know that the atexit handler will always be called early enough? |
1st1
commented
Nov 7, 2016
I agree. I'm myself not feeling comfortable, even two of us doesn't seem to be enough to support asyncio. @asvetlov, @methane and @Haypo: are you interested to help us with asyncio? At least to offer help with PRs and participate in related discussions.
|
I think the PR makes sense: we raise |
gvanrossum
commented
Nov 9, 2016
via email
OK, then LGTM. |
vxgmichel
commented
Nov 9, 2016
gvanrossum
commented
Nov 9, 2016
via email
If something needs to be changed in signalmodule.c please open an issue on
bugs.python.org. |
1st1
commented
Nov 9, 2016
Yes, the bug in _signal can (and should) be fixed, and I have a working patch for that. My worry is that it might be a bit too late to do that for 3.6. I'll submit the patch and ask Ned's opinion. |
1st1
commented
Nov 9, 2016
I've no idea what's going on. I can reproduce this bug with python installed from MacPorts. I can't reproduce it with python I build from source. |
1st1
commented
Nov 9, 2016
The bug is the following program: importsignalimportasynciodeffoo():
passasyncdefbar():
passdefmain():
loop=asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, lambda: None)
loop.add_signal_handler(signal.SIGHUP, lambda: None)
loop.run_until_complete(bar())
if__name__=="__main__":
main()It should spit out something like this: |
gvanrossum
commented
Nov 9, 2016
via email
Maybe they ran configure with different parameters or in a different
context or with a different version of Xcode? |
1st1
commented
Nov 9, 2016
Maybe. It should be something that changes how & when objects are GCed. The above traceback happens when objects are GCed after the signals module is finalized (and that's what I've seen in reports from asyncio and uvloop users). I'll try to get to the bottom of this. |
vxgmichel
commented
Nov 9, 2016
@1st1 My results:
|
I think I've figured out what's going on with
remove_signal_handler.This PR fixes: