Multiprocessing Fail

Terrence Cole list-sink at trainedmonkeystudios.org
Sun Oct 11 21:10:36 EDT 2009


This code fails:
######
from multiprocessing import Manager
manager = Manager()
ns_proxy = manager.Namespace()
evt_proxy = manager.Event()
ns_proxy.my_event_proxy = evt_proxy
print ns_proxy.my_event_proxy
######
Traceback (most recent call last):
  File "test_nsproxy.py", line 39, in <module>
    print ns_proxy.my_event_proxy
  File "/usr/lib64/python2.6/multiprocessing/managers.py", line 989, in
__getattr__
    return callmethod('__getattribute__', (key,))
  File "/usr/lib64/python2.6/multiprocessing/managers.py", line 740, in
_callmethod
    raise convert_to_error(kind, result)
multiprocessing.managers.RemoteError:
---------------------------------------------------------------------------
Unserializable message: ('#RETURN', <threading._Event object at
0x1494790>)
---------------------------------------------------------------------------

This code creates a manager, uses the manager to create a Namespace and
an Event.  We store the proxies in variables 'ns_proxy' and 'evt_proxy'
respectively.  We set the name 'my_event_proxy' on the namespace proxy
with the event proxy.  This appears to pickle, transmit, and store the
event proxy successfully.  However, when we attempt to read back the
event proxy from the namespace proxy, we get an exception.  It appears
that the namespace is attempting to return the real event and not the
proxy and, of course, the real event is not pickable.  The same error
occurs if we substitute a dict or a list for the Namespace or any of the
synchronization primitives for Event.  The docs seem to indicate that
nesting of manager elements should work.

What is wrong here, multiprocessing's docs or its implementation?

I tested this on:
Python 2.6.2 (r262:71600, Sep 14 2009, 18:47:57)
[GCC 4.3.2] on linux2
and:
Python 2.7a0 (trunk:75375, Oct 11 2009, 17:50:44)
[GCC 4.3.2] on linux2
with the same results on both.

-Terrence




More information about the Python-list mailing list