Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

_DummyThreads can be joined in-OO mode #106236

Closed
Assignees
sobolevn
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@sobolevn

Description

@sobolevn

Right now_DummyThread claims to not allowjoin:

cpython/Lib/threading.py

Lines 1453 to 1458 infb0d9b9

defis_alive(self):
assertnotself._is_stoppedandself._started.is_set()
returnTrue
defjoin(self,timeout=None):
assertFalse,"cannot join a dummy thread"

But, it can be easily changed withpython -OO mode, which stripsassert statements.

The easiest way to check this is:

# ex.pyimportthreading,_threaddeff(mutex):threading.current_thread()mutex.release()mutex=threading.Lock()mutex.acquire()tid=_thread.start_new_thread(f, (mutex,))mutex.acquire()threading._active[tid].join()print('done')

python ex.py results in:

Traceback (most recent call last):  File "/Users/sobolev/Desktop/cpython/ex.py", line 12, in <module>    threading._active[tid].join()  File "/Users/sobolev/Desktop/cpython/Lib/threading.py", line 1458, in join    assert False, "cannot join a dummy thread"AssertionError: cannot join a dummy thread

But,python -OO ex.py results in:

done

This looks like an important behavior change. I propose to use explicitAssertionError /RuntimeError instead.

I have a PR ready.

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp