Multiprocessing Fail

Discussion in 'Python' started by Terrence Cole, Oct 12, 2009.

  1. 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
    Terrence Cole, Oct 12, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wenjie

    if (f() != FAIL) or if (FAIL != f())?

    Wenjie, Jul 28, 2003, in forum: C Programming
    Replies:
    3
    Views:
    426
    E. Robert Tisdale
    Jul 31, 2003
  2. Amit N
    Replies:
    4
    Views:
    512
    Paddy
    Sep 13, 2007
  3. sturlamolden

    multiprocessing module (PEP 371)

    sturlamolden, Jun 4, 2008, in forum: Python
    Replies:
    6
    Views:
    425
    John Nagle
    Jun 8, 2008
  4. Max Ivanov

    multiprocessing eats memory

    Max Ivanov, Sep 25, 2008, in forum: Python
    Replies:
    6
    Views:
    323
    redbaron
    Sep 27, 2008
  5. Aaron \Castironpi\ Brady

    2.6 multiprocessing and pdb

    Aaron \Castironpi\ Brady, Oct 2, 2008, in forum: Python
    Replies:
    1
    Views:
    656
    Gabriel Genellina
    Oct 3, 2008
Loading...

Share This Page