0
0
mirror of https://github.com/python/cpython.git synced 2024-11-24 00:38:00 +01:00
cpython/Lib/multiprocessing
Petr Viktorin ba088c8f9c
gh-71936: Fix race condition in multiprocessing.Pool (GH-124973)
* gh-71936: Fix race condition in multiprocessing.Pool

Proxes of shared objects register a Finalizer in BaseProxy._incref(), and it
will call BaseProxy._decref() when it is GCed. This may cause a race condition
with Pool(maxtasksperchild=None) on Windows.

A connection would be closed and raised TypeError when a GC occurs between
_ConnectionBase._check_writable() and _ConnectionBase._send_bytes() in
_ConnectionBase.send() in the second or later task, and a new object
is allocated that shares the id() of a previously deleted one.

Instead of using the id() of the token (or the proxy), use a unique,
non-reusable number.

Co-Authored-By: Akinori Hattori <hattya@gmail.com>
2024-11-13 10:25:10 +01:00
..
dummy
__init__.py
connection.py
context.py
forkserver.py
heap.py
managers.py gh-71936: Fix race condition in multiprocessing.Pool (GH-124973) 2024-11-13 10:25:10 +01:00
pool.py
popen_fork.py
popen_forkserver.py
popen_spawn_posix.py
popen_spawn_win32.py
process.py
queues.py
reduction.py
resource_sharer.py
resource_tracker.py
shared_memory.py
sharedctypes.py
spawn.py
synchronize.py
util.py