Repository navigation
Sync remaining Python 3.15.2 test isolation helpers and coverage #9911
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -686,6 +686,24 @@ def fd_count(): | |
| except FileNotFoundError: | ||
| pass | ||
|
|
||
| if sys.platform == "freebsd" and fd_count._dev_fd_mounted: | ||
| # Check if /dev/fd/ fdescfs file system is mounted. By default, it's | ||
| # not mounted and /dev/fd/ always contains 3 files (0, 1, 2). | ||
| try: | ||
| dirfd = os.open("/dev/fd", os.O_RDONLY) | ||
| try: | ||
| if os.path.exists(f"/dev/fd/{dirfd}"): | ||
| names = list(os.scandir(dirfd)) | ||
| # Don't count dirfd | ||
| return len(names) - 1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| else: | ||
| # fdescfs is not mounted | ||
| fd_count._dev_fd_mounted = False | ||
| finally: | ||
| os.close(dirfd) | ||
| except FileNotFoundError: | ||
| pass | ||
|
|
||
| MAXFD = 256 | ||
| if hasattr(os, 'sysconf'): | ||
| try: | ||
|
|
@@ -733,6 +751,9 @@ def fd_count(): | |
|
|
||
| return count | ||
|
|
||
| # On FreeBSD, flag set to False if /dev/fd/ is not mounted as fdescfs | ||
| fd_count._dev_fd_mounted = True | ||
|
|
||
|
|
||
| if hasattr(os, "umask"): | ||
| @contextlib.contextmanager | ||
|
|
||
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.
If the waiting parent receives
KeyboardInterruptwhile the worker ignores or does not receive SIGINT, or iftick()raises, thisfinallyblock only deletes the result file: the worker remains running and its captured pipes remain open. The previoussubprocess.run()path killed the worker on exceptions, so interrupting a long-running isolated test now leaks a process that can continue consuming memory and CPU. Add exceptional-exit cleanup to terminate and reap the worker and close its pipes.Useful? React with 👍 / 👎.