Skip to content
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

test_asyncio.test_unix_events: test_fork_signal_handling() fails randomly on Linux/macOS #109582

Closed
vstinner opened this issue Sep 19, 2023 · 5 comments
Labels
tests Tests in the Lib/test dir topic-asyncio

Comments

@vstinner
Copy link
Member

vstinner commented Sep 19, 2023

FAIL: test_fork_signal_handling (test.test_asyncio.test_unix_events.TestFork.test_fork_signal_handling)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/runner/work/cpython/cpython/Lib/unittest/async_case.py", line 90, in _callTestMethod
    if self._callMaybeAsync(method) is not None:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/work/cpython/cpython/Lib/unittest/async_case.py", line 117, in _callMaybeAsync
    return self._asyncioTestContext.run(func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/work/cpython/cpython/Lib/test/support/hashlib_helper.py", line 49, in wrapper
    return func_or_class(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/work/cpython/cpython/Lib/test/test_asyncio/test_unix_events.py", line 1937, in test_fork_signal_handling
    self.assertTrue(child_handled.is_set())
AssertionError: False is not true

build: https://github.com/python/cpython/actions/runs/6237986497/job/16932828971

Passed when re-run:

Re-running test.test_asyncio.test_unix_events in verbose mode (matching: test_fork_signal_handling)
test_fork_signal_handling (test.test_asyncio.test_unix_events.TestFork.test_fork_signal_handling) ... /Users/runner/work/cpython/cpython/Lib/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=14768) is multi-threaded, use of fork() may lead to deadlocks in the child.
  self.pid = os.fork()
ok

Linked PRs

@vstinner vstinner added tests Tests in the Lib/test dir topic-asyncio labels Sep 19, 2023
@github-project-automation github-project-automation bot moved this to Todo in asyncio Sep 19, 2023
@vstinner
Copy link
Member Author

It also fails on s390x RHEL8 Refleaks 3.x: https://buildbot.python.org/all/#/builders/75/builds/889

@vstinner vstinner changed the title test_asyncio.test_unix_events: test_fork_signal_handling() failed on GHA macOS job test_asyncio.test_unix_events: test_fork_signal_handling() fails randomly on Linux/macOS Sep 20, 2023
@vstinner
Copy link
Member Author

Fail on PPC64LE RHEL8 LTO 3.x: https://buildbot.python.org/all/#/builders/361/builds/4075

@sorcio
Copy link
Contributor

sorcio commented Sep 20, 2023

@sorcio
Copy link
Contributor

sorcio commented Sep 20, 2023

Could be an easy fix: #109605

On first glance I don't see other tests with the same pattern so I only fixed the one.

vstinner pushed a commit that referenced this issue Sep 21, 2023
Sometimes the child_handled event was missing because either
the child quits before it gets a chance to handle the signal,
or the parent asserts before the event notification is
delivered via IPC.  Synchronize explicitly to avoid this.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 21, 2023
…honGH-109605)

Sometimes the child_handled event was missing because either
the child quits before it gets a chance to handle the signal,
or the parent asserts before the event notification is
delivered via IPC.  Synchronize explicitly to avoid this.
(cherry picked from commit 608c1f3)

Co-authored-by: Davide Rizzo <[email protected]>
@vstinner
Copy link
Member Author

Fixed by 608c1f3. Thanks @sorcio!

@github-project-automation github-project-automation bot moved this from Todo to Done in asyncio Sep 21, 2023
csm10495 pushed a commit to csm10495/cpython that referenced this issue Sep 28, 2023
…hon#109605)

Sometimes the child_handled event was missing because either
the child quits before it gets a chance to handle the signal,
or the parent asserts before the event notification is
delivered via IPC.  Synchronize explicitly to avoid this.
Yhg1s pushed a commit that referenced this issue Oct 2, 2023
…-109605) (#109695)

gh-109582: test_fork_signal_handling should wait for event (GH-109605)

Sometimes the child_handled event was missing because either
the child quits before it gets a chance to handle the signal,
or the parent asserts before the event notification is
delivered via IPC.  Synchronize explicitly to avoid this.
(cherry picked from commit 608c1f3)

Co-authored-by: Davide Rizzo <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…hon#109605)

Sometimes the child_handled event was missing because either
the child quits before it gets a chance to handle the signal,
or the parent asserts before the event notification is
delivered via IPC.  Synchronize explicitly to avoid this.
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 topic-asyncio
Projects
Status: Done
Development

No branches or pull requests

2 participants