aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Lib/multiprocessing/managers.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-12-23 19:39:02 +0300
committershadchin <shadchin@yandex-team.com>2024-12-23 19:54:20 +0300
commit65a5bf9d37a3b29eb394f560b9a09318196c40e8 (patch)
treee5cd68fb0682b2388e52d9806bb87adc348e21a8 /contrib/tools/python3/Lib/multiprocessing/managers.py
parenta1dd87a52878ab3e46e5fd2dba5ecbba6113d7e0 (diff)
downloadydb-65a5bf9d37a3b29eb394f560b9a09318196c40e8.tar.gz
Update Python 3 to 3.12.8
commit_hash:c20045b8a987d8720e1f3328270357491d5530f3
Diffstat (limited to 'contrib/tools/python3/Lib/multiprocessing/managers.py')
-rw-r--r--contrib/tools/python3/Lib/multiprocessing/managers.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/contrib/tools/python3/Lib/multiprocessing/managers.py b/contrib/tools/python3/Lib/multiprocessing/managers.py
index 75d9c18c20..010d16e149 100644
--- a/contrib/tools/python3/Lib/multiprocessing/managers.py
+++ b/contrib/tools/python3/Lib/multiprocessing/managers.py
@@ -755,22 +755,29 @@ class BaseProxy(object):
_address_to_local = {}
_mutex = util.ForkAwareThreadLock()
+ # Each instance gets a `_serial` number. Unlike `id(...)`, this number
+ # is never reused.
+ _next_serial = 1
+
def __init__(self, token, serializer, manager=None,
authkey=None, exposed=None, incref=True, manager_owned=False):
with BaseProxy._mutex:
- tls_idset = BaseProxy._address_to_local.get(token.address, None)
- if tls_idset is None:
- tls_idset = util.ForkAwareLocal(), ProcessLocalSet()
- BaseProxy._address_to_local[token.address] = tls_idset
+ tls_serials = BaseProxy._address_to_local.get(token.address, None)
+ if tls_serials is None:
+ tls_serials = util.ForkAwareLocal(), ProcessLocalSet()
+ BaseProxy._address_to_local[token.address] = tls_serials
+
+ self._serial = BaseProxy._next_serial
+ BaseProxy._next_serial += 1
# self._tls is used to record the connection used by this
# thread to communicate with the manager at token.address
- self._tls = tls_idset[0]
+ self._tls = tls_serials[0]
- # self._idset is used to record the identities of all shared
- # objects for which the current process owns references and
+ # self._all_serials is a set used to record the identities of all
+ # shared objects for which the current process owns references and
# which are in the manager at token.address
- self._idset = tls_idset[1]
+ self._all_serials = tls_serials[1]
self._token = token
self._id = self._token.id
@@ -850,20 +857,20 @@ class BaseProxy(object):
dispatch(conn, None, 'incref', (self._id,))
util.debug('INCREF %r', self._token.id)
- self._idset.add(self._id)
+ self._all_serials.add(self._serial)
state = self._manager and self._manager._state
self._close = util.Finalize(
self, BaseProxy._decref,
- args=(self._token, self._authkey, state,
- self._tls, self._idset, self._Client),
+ args=(self._token, self._serial, self._authkey, state,
+ self._tls, self._all_serials, self._Client),
exitpriority=10
)
@staticmethod
- def _decref(token, authkey, state, tls, idset, _Client):
- idset.discard(token.id)
+ def _decref(token, serial, authkey, state, tls, idset, _Client):
+ idset.discard(serial)
# check whether manager is still alive
if state is None or state.value == State.STARTED: