Repository navigation
Conversation
|
The following commit authors need to sign the Contributor License Agreement: |
|
Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate. Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors. We believe this contribution does not meet our guidelines for using AI tools, so we're closing it. If you think we've misunderstood your contribution, please let us know. You're welcome to explain your approach or ask questions about the guidelines. Please read our guidelines for using AI tools. |
Problem
A proxy's
BaseProxy._decreffinalizer synchronously opens a new connection and waits for the manager to answer. When the manager server runs in the same process, cyclic GC can invoke the finalizer on its own accepter thread, or whileServer.createholds its mutex. In either case the finalizer waits for work that the blocked server thread cannot complete, permanently deadlocking a live manager. This is reproducible with in-process threadedserve_forever()and is reported in Apache Beam.Change
Keep a weak registry of
Serverinstances running inside the current process (with PID checking to avoid using a stale registry after fork). In-process proxy finalizers enqueue decref identifiers instead of opening a blocking RPC. The server's existingserve_foreverloop consumes these decrements outside the accepter and request threads; remote-manager finalizers retain the existing RPC path. The registry accommodates multiple servers, and entries are retired when servers stop.Test
Add a deterministic subprocess regression that forces cyclic GC during the accepter's new request-thread creation, both with one and with multiple local manager servers. It asserts the RPC completes rather than deadlocking, and that queued decrements are eventually processed. The earlier isolated run of the exact pushed branch
fix/gh-159986-manager-local-decref(tip4a95ae9) reported 276 manager tests passing. The presenting agent reviewed the deadlock and queue-based fix; no fresh full test suite run is asserted here.AI disclosure
Implemented and tested with autonomous GPT-6 assistance; reviewed by the presenting assistant. No human review is claimed.
Fixes #159986.