[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

bpo-39511: PyThreadState_Clear() calls on_delete by vstinner · Pull Request #18296 · python/cpython

the-knights-who-say-ni

PyThreadState.on_delete is a callback used to notify Python when a
thread completes. _thread._set_sentinel() function creates a lock
which is released when the thread completes. It sets on_delete
callback to the internal release_sentinel() function. This lock is
known as Threading._tstate_lock in the threading module.

The release_sentinel() function uses the Python C API. The problem is
that on_delete is called late in the Python finalization, when the C
API is no longer fully working.

The PyThreadState_Clear() function now calls the
PyThreadState.on_delete callback. Previously, that happened in
PyThreadState_Delete().

The release_sentinel() function is now called when the C API is still
fully working.

vstinner merged commit 4d96b46 into python:master

Feb 1, 2020

9 checks passed

Azure Pipelines PR #20200201.1 succeeded

Details

bedevere/issue-number Issue number 39511 found

Details

bedevere/news News entry found in Misc/NEWS.d

continuous-integration/travis-ci/pr The Travis CI build passed

Details

vstinner deleted the vstinner:zapthreads branch

Feb 1, 2020

petdance added a commit to petdance/cpython that referenced this pull request

Feb 2, 2020
PyThreadState.on_delete is a callback used to notify Python when a
thread completes. _thread._set_sentinel() function creates a lock
which is released when the thread completes. It sets on_delete
callback to the internal release_sentinel() function. This lock is
known as Threading._tstate_lock in the threading module.

The release_sentinel() function uses the Python C API. The problem is
that on_delete is called late in the Python finalization, when the C
API is no longer fully working.

The PyThreadState_Clear() function now calls the
PyThreadState.on_delete callback. Previously, that happened in
PyThreadState_Delete().

The release_sentinel() function is now called when the C API is still
fully working.