summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/managers.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-09-01 17:10:46 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-09-01 17:10:46 (GMT)
commitf7feaec16c6d21cbb3c6c5c9b84288dd3095c005 (patch)
treedf1c7b1330e30a1a4f369863749cb0c586d9af2a /Lib/multiprocessing/managers.py
parent27cc8e1dd2846ff8df18b5d776192d4f99354a26 (diff)
downloadcpython-f7feaec16c6d21cbb3c6c5c9b84288dd3095c005.zip
cpython-f7feaec16c6d21cbb3c6c5c9b84288dd3095c005.tar.gz
cpython-f7feaec16c6d21cbb3c6c5c9b84288dd3095c005.tar.bz2
revert r66114 for Jesse
Diffstat (limited to 'Lib/multiprocessing/managers.py')
-rw-r--r--Lib/multiprocessing/managers.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index 256e572..f32dab1 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -371,7 +371,13 @@ class Server(object):
self.id_to_obj[ident] = (obj, set(exposed), method_to_typeid)
if ident not in self.id_to_refcount:
- self.id_to_refcount[ident] = None
+ self.id_to_refcount[ident] = 0
+ # increment the reference count immediately, to avoid
+ # this object being garbage collected before a Proxy
+ # object for it can be created. The caller of create()
+ # is responsible for doing a decref once the Proxy object
+ # has been created.
+ self.incref(c, ident)
return ident, tuple(exposed)
finally:
self.mutex.release()
@@ -393,11 +399,7 @@ class Server(object):
def incref(self, c, ident):
self.mutex.acquire()
try:
- try:
- self.id_to_refcount[ident] += 1
- except TypeError:
- assert self.id_to_refcount[ident] is None
- self.id_to_refcount[ident] = 1
+ self.id_to_refcount[ident] += 1
finally:
self.mutex.release()
@@ -634,6 +636,8 @@ class BaseManager(object):
token, self._serializer, manager=self,
authkey=self._authkey, exposed=exp
)
+ conn = self._Client(token.address, authkey=self._authkey)
+ dispatch(conn, None, 'decref', (token.id,))
return proxy
temp.__name__ = typeid
setattr(cls, typeid, temp)
@@ -726,10 +730,13 @@ class BaseProxy(object):
elif kind == '#PROXY':
exposed, token = result
proxytype = self._manager._registry[token.typeid][-1]
- return proxytype(
+ proxy = proxytype(
token, self._serializer, manager=self._manager,
authkey=self._authkey, exposed=exposed
)
+ conn = self._Client(token.address, authkey=self._authkey)
+ dispatch(conn, None, 'decref', (token.id,))
+ return proxy
raise convert_to_error(kind, result)
def _getvalue(self):