Repository navigation
Open the Linux pidfd as a binary FileIO - #3555
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3555 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19475 19480 +5
Branches 1323 1323
===============================================
+ Hits 19475 19480 +5
🚀 New features to boost your workflow:
|
Process wrapped its pidfd with open(fd), which is text mode with the locale's default encoding. Under -X warn_default_encoding (or PYTHONWARNDEFAULTENCODING=1) that emits an EncodingWarning every time a process is spawned, which fails test suites that turn warnings into errors. The pidfd is only ever waited on and closed, never read, so wrap it in a plain FileIO instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5JBb9ya4c5gRtm9ug1PyS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5JBb9ya4c5gRtm9ug1PyS
e83c17f to
3f8bb02
Compare
| self._wait_lock: Lock = Lock() | ||
|
|
||
| self._pidfd: TextIOWrapper | None = None | ||
| self._pidfd: FileIO | None = None |
There was a problem hiding this comment.
I'm actually surprised this explicit type hint is/was necessary. Maybe mypy has improved so it infers this now?
There was a problem hiding this comment.
The test seems a little weird but I guess I can't think of another way to test that. Had to read up on io.FileIO, and yes I think this would be a great use case for it. Though I'm slightly worried about this line:
... members, such as read() and write(), need to have their return values checked explicitly in a retry loop to implement “write all” and “read at least” behavior.
Do we need to worry about that?
|
nope - we never read or write this file descriptor, just wait on it. |
Process wrapped its pidfd with
open(fd), which is text mode with the locale's default encoding. Under-X warn_default_encodingthat emits anEncodingWarningevery time a process is spawned, which fails test suites that turn warnings into errors. The pidfd is only ever waited on and closed, never read, so wrap it in a plainFileIOinstead.