Skip to content

test_repl: Warning -- reap_children() reaped child process 3457256 #120635

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

Closed
vstinner opened this issue Jun 17, 2024 · 4 comments
Closed

test_repl: Warning -- reap_children() reaped child process 3457256 #120635

vstinner opened this issue Jun 17, 2024 · 4 comments
Labels
tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

vstinner commented Jun 17, 2024

On the "AMD64 Debian PGO 3.x" buildbot worker, test_pyrepl fails with "env changed" because a child process is not awaited explicitly.

build: https://buildbot.python.org/all/#/builders/249/builds/8909

1:17:07 load avg: 20.12 [453/478/1] test_pyrepl failed (env changed) (37.4 sec)
test_empty (test.test_pyrepl.test_input.KeymapTranslatorTests.test_empty) ... ok
test_push_character_key (test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_character_key) ... ok
test_push_character_key_with_stack (test.test_pyrepl.test_input.KeymapTranslatorTests.test_push_character_key_with_stack) ... ok
(...)
test.test_pyrepl.test_windows_console (unittest.loader.ModuleSkipped.test.test_pyrepl.test_windows_console) ... skipped 'test only relevant on win32'

----------------------------------------------------------------------
Ran 116 tests in 35.634s

OK (skipped=2)
Warning -- reap_children() reaped child process 3457256

Linked PRs

@vstinner vstinner added the tests Tests in the Lib/test dir label Jun 17, 2024
@vstinner
Copy link
Member Author

Sadly, I fail to reproduce the issues locally.

@encukou
Copy link
Member

encukou commented Jun 18, 2024

The commits added for the first failed run were 1b62bce, 86a8a1c & 939c201. One of them adds a pyrepl test that runs a subprocess:

vstinner added a commit to vstinner/cpython that referenced this issue Jun 18, 2024
If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
vstinner added a commit to vstinner/cpython that referenced this issue Jun 18, 2024
If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
@vstinner
Copy link
Member Author

I managed to reproduce the issue with this change:

diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index 41ba5959a1..0c22260741 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -887,7 +887,7 @@ def run_repl(self, repl_input: str | list[str], env: dict | None = None) -> tupl
         os.close(master_fd)
         os.close(slave_fd)
         try:
-            exit_code = process.wait(timeout=SHORT_TIMEOUT)
+            exit_code = process.wait(timeout=1.0)
         except subprocess.TimeoutExpired:
             process.kill()
             exit_code = process.returncode

And the command:

./python -m test test_pyrepl -u all -W -F -j100 --fail-env-changed -m test_dumb_terminal_exits_cleanly -m test_exposed_globals_in_repl

@vstinner
Copy link
Member Author

I wrote a fix: #120676.

vstinner added a commit that referenced this issue Jun 19, 2024
If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 19, 2024
)

If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
(cherry picked from commit 0f3e364)

Co-authored-by: Victor Stinner <[email protected]>
vstinner added a commit that referenced this issue Jun 19, 2024
…120741)

gh-120635: Avoid leaking processes in test_pyrepl (GH-120676)

If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
(cherry picked from commit 0f3e364)

Co-authored-by: Victor Stinner <[email protected]>
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
If the child process takes longer than SHORT_TIMEOUT seconds to
complete, kill the process but then wait until it completes with no
timeout to not leak child processes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

No branches or pull requests

2 participants