SIGN IN SIGN UP

[3.12] gh-71936: Fix race condition in multiprocessing.Pool (GH-124973) (GH-126870)

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.

(cherry picked from commit ba088c8f9cf7163b0f28c507cb1343befe21997e)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Akinori Hattori <hattya@gmail.com>
M
Miss Islington (bot) committed
d0d892f7a320fa5baf3f304c94d02056b19a9799
Parent: ef0a005
Committed by GitHub <noreply@github.com> on 11/15/2024, 2:04:35 PM