-
Notifications
You must be signed in to change notification settings - Fork 146
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
Handle case where output buffer is closed during shutdown #365
Conversation
- Prevent crash during launch shutdown when a process IO event happens after the buffers have been closed - Use unbuffered output in that case so IO still has a chance of being seen Signed-off-by: Pete Baughman <[email protected]>
@ivanpauno Some code duplication, but fixes the crash on shutdown in the nightly docker image |
@wjwwood fyi and ask if we can get this in a little faster. |
self.__stdout_buffer.write(last_line) | ||
except ValueError: | ||
# __stdout_buffer was probably closed by __flush_buffers on shutdown. Output without | ||
# buffering. |
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.
@pbaughman why not checking if self.__stdout_buffer.closed
instead of hoping ValueError
was raised for the reasons you expect?
self.__stderr_buffer.write(last_line) | ||
except ValueError: | ||
# __stderr buffer was probably closed by __flush_buffers on shutdown. Output without | ||
# buffering. |
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.
@pbaughman same as above.
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.
@hidmic Yeah, I was coming at this from the approach of "this is a race condition" but this method is synchronized with the one that closes the buffers, right? They're not going to get closed out from under us while the method is running?
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.
It's asyncio
, so no, that won't happen. There're no guarantees regarding execution order, and that's what probably caused this issue in the first place.
Signed-off-by: Pete Baughman <[email protected]>
@hidmic I've addressed your comments |
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.
LGTM pending green CI
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.
LGTM!
@hidmic The windows failure looks like a problem with building, not testing. |
Alright, going in! |
* Handle case where output buffer is closed during shutdown - Prevent crash during launch shutdown when a process IO event happens after the buffers have been closed - Use unbuffered output in that case so IO still has a chance of being seen Signed-off-by: Pete Baughman <[email protected]> * Address MR feedback Signed-off-by: Pete Baughman <[email protected]>
* Handle case where output buffer is closed during shutdown - Prevent crash during launch shutdown when a process IO event happens after the buffers have been closed - Use unbuffered output in that case so IO still has a chance of being seen Signed-off-by: Pete Baughman <[email protected]> * Address MR feedback Signed-off-by: Pete Baughman <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]>
* Handle case where output buffer is closed during shutdown (#365) * Handle case where output buffer is closed during shutdown - Prevent crash during launch shutdown when a process IO event happens after the buffers have been closed - Use unbuffered output in that case so IO still has a chance of being seen Signed-off-by: Pete Baughman <[email protected]> * Address MR feedback Signed-off-by: Pete Baughman <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]> * Import test file without contaminating sys.modules (#360) Signed-off-by: Pete Baughman <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]> * Release loop lock before waiting for it to do work (#369) Main thread can be blocked trying to acquire __loop_from_run_thread_lock while emit_event() in another thread is holding that lock and waiting for the main thread to emit the event. This change releases the lock before blocking. Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: Ivan Santiago Paunovic <[email protected]> Co-authored-by: Peter Baughman <[email protected]> Co-authored-by: Shane Loretz <[email protected]>
Prevent crash during launch shutdown when a process IO event happens
after the buffers have been closed
Use unbuffered output in that case so IO still has a chance of being seen
Fixes #364
Signed-off-by: Pete Baughman [email protected]