-
Notifications
You must be signed in to change notification settings - Fork 145
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
Workaround asyncio signal handling on Unix #479
Conversation
Unix asyncio loops override existing signal wakeup file descriptors with no regards for existing ones -- set by user code or by another loop Signed-off-by: Michel Hidalgo <[email protected]>
I'll open another ticket upstream. |
Signed-off-by: Michel Hidalgo <[email protected]>
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'm not really comfortable with the fact that this PR overwrites signal.set_wakeup_fd
, but the code looks reasonable and I don't know how to fix this in another way.
It's worth writing a big comment explaining why this is being done in the code.
LGTM with nits addressed.
Signed-off-by: Michel Hidalgo <[email protected]>
@ivanpauno PTAL @ a15958a |
does this PR mean that signal handlers added with asyncio.loop.add_signal_handler are ignored if you later happen to asynchronously launch a process? Really, that's pretty broken 😄 .... |
|
But now that I think about it, I should enforce it for the |
I mean, does something like: loop.add_signal_handler(...)
# first process launch in next line, child watcher initialized there
process = asyncio.create_subprocess_exec(...) work, or is that also broken? If that's not broken, if they would support |
If it's the same loop for both calls, it works. If it's different loops, last one wins :D |
Signed-off-by: Michel Hidalgo <[email protected]>
f90f8bc should take care of multi-threaded scenarios. It's (I think) exception-safe too. |
Alright, all's green and reviewer's happy. Going in! |
Unix asyncio loops override existing signal wakeup file descriptors with no regards for existing ones -- set by user code or by another loop Signed-off-by: Michel Hidalgo <[email protected]>
Unix asyncio loops override existing signal wakeup file descriptors with no regards for existing ones -- set by user code or by another loop Signed-off-by: Michel Hidalgo <[email protected]>
* Handle signals within the asyncio loop. (#476) * Workaround asyncio signal handling on Unix (#479) * Remove is_winsock_handle() and instead test if wrapping the handle in a socket.socket() works (#494) * Close the socket pair used for signal management (#497) * Only try to wrap the fd in a socket on Windows (#498) * Bring back deprecated launch.utilities.signal_management APIs Signed-off-by: Michel Hidalgo <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Unix
asyncio
loops override existing signal wakeup file descriptors with no regards for existing ones -- set by user code or by another loop. For further reference, see here. This is a problem when the child watcher gets lazy initialized (e.g. on first async subprocess execution, see here and here).CI up to
launch
: