mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-105699: Use a Thread-Local Variable for PKGCONTEXT (gh-105740)
This fixes a race during import. The existing _PyRuntimeState.imports.pkgcontext is shared between interpreters, and occasionally this would cause a crash when multiple interpreters were importing extensions modules at the same time. To solve this we add a thread-local variable for the value. We also leave the existing state (and infrequent race) in place for platforms that do not support thread-local variables.
This commit is contained in:
parent
fcf0647cf2
commit
b87d288275
4 changed files with 24 additions and 1 deletions
|
@ -219,6 +219,7 @@ def _strip_directives(line, partial=0):
|
|||
line = line[m.end():]
|
||||
|
||||
line = re.sub(r'__extension__', '', line)
|
||||
line = re.sub(r'__thread\b', '_Thread_local', line)
|
||||
|
||||
while (m := COMPILER_DIRECTIVE_RE.match(line)):
|
||||
before, _, _, closed = m.groups()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue