这是indexloc提供的服务,不要输入任何密码
Skip to content

Resolve #2111 and #2120: Allow _DummyThread.is_alive to return False after fork #2122

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

embray
Copy link

@embray embray commented Jul 2, 2025

For me this resolves #2111 on Python 3.11.x

While we're at it also resolve #2120

Supersedes #2117

@embray embray changed the title Resolve #2111: Allow _DummyThread.is_alive to return False after fork Resolve #2111 and #2120: Allow _DummyThread.is_alive to return False after fork Jul 2, 2025
# Instead, allow _DummyThreads to actually return False for is_alive() if it's been
# cleaned up after a fork.
def isAlive(self):
return not self._is_stopped
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, turns out since Python 3.13 _DummyThread.is_alive() is actually:

    def is_alive(self):
        if not self._handle.is_done() and self._started.is_set():
            return True
        raise RuntimeError("thread is not alive")

So that's a bit of a digression from my earlier plan for this... Maybe it would be better to simply not assert not thread.is_alive() for dummy threads because the intended semantics seem to be this is either always True or undefined behavior...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError in threading.py for Python 3.13.5 Exception ignored, AssertionError
1 participant