Fix potential deadlock in tty.log writer_daemon [AI]#1639
Fix potential deadlock in tty.log writer_daemon [AI]#1639douglasjacobsen wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the log utility to close sys.stdout when exiting the context. The review feedback suggests wrapping the restoration of sys.stdout and sys.stderr in a finally block to guarantee they are restored even if a BaseException (such as KeyboardInterrupt) is raised during the close operation.
Ramble Performance Test MetricsResults produced with commit: 28aeded
|
f6cdbfe to
2b946bf
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request modifies the exit method in lib/ramble/llnl/util/tty/log.py to attempt to close sys.stdout before restoring the saved stdout and stderr streams. The reviewer recommended extending this to close both sys.stdout and sys.stderr to avoid potential pipe leaks and deadlocks if sys.stdout was reassigned during the block.
When use_fds falls back to False (which occurs when pytest replaces standard file descriptors with its StringIO streams for capture via capsys ), sys.stdout was not being correctly closed upon context exit. This caused the pipe to leak and the main process to wait indefinitely on the daemon to exit.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1639 +/- ##
========================================
Coverage 93.20% 93.20%
========================================
Files 346 346
Lines 33451 33451
========================================
Hits 31179 31179
Misses 2272 2272 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2b946bf to
28aeded
Compare
|
Thanks for the fix. Personally I prefer the wholesale update from #1644 over this patch. |
When
use_fdsfalls back toFalse(which occurs when pytest replaces standard file descriptors with its StringIO streams for capture via capsys ), sys.stdout was not being correctly closed upon context exit. This caused the pipe to leak and the main process to wait indefinitely on the daemon to exit.