mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-117657: Fix race involving immortalizing objects (#119927)
The free-threaded build currently immortalizes objects that use deferred reference counting (see gh-117783). This typically happens once the first non-main thread is created, but the behavior can be suppressed for tests, in subinterpreters, or during a compile() call. This fixes a race condition involving the tracking of whether the behavior is suppressed.
This commit is contained in:
parent
b8fde5db86
commit
47fb4327b5
9 changed files with 30 additions and 44 deletions
|
@ -529,11 +529,11 @@ def suppress_immortalization(suppress=True):
|
|||
yield
|
||||
return
|
||||
|
||||
old_values = _testinternalcapi.set_immortalize_deferred(False)
|
||||
_testinternalcapi.suppress_immortalization(True)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
_testinternalcapi.set_immortalize_deferred(*old_values)
|
||||
_testinternalcapi.suppress_immortalization(False)
|
||||
|
||||
def skip_if_suppress_immortalization():
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue