Need help with multiprocessing.manager and passing the manager amultiprocessing.Connection

Discussion in 'Python' started by Metalone, Jan 6, 2010.

  1. Metalone

    Metalone Guest

    The following code snippet is taken from the Python 2.6
    multiprocessing documentation with a simple change and this change
    does not work. I would like to know how to make it work or something
    similar.
    I want to pass a Connection object to the MathsClass.
    I get the following error on Windows:

    Traceback (most recent call last):
    File "c:\apps\python26\lib\multiprocessing\managers.py", line 214,
    in serve_cl
    ient
    request = recv()
    TypeError: Required argument 'handle' (pos 1) not found


    from multiprocessing.managers import BaseManager
    from multiprocessing import Pipe # I added this

    class MathsClass(object):
    def set(self, conn): # I added the set() function
    self.conn = conn
    def add(self, x, y):
    return x + y
    def mul(self, x, y):
    return x * y

    class MyManager(BaseManager):
    pass

    MyManager.register('Maths', MathsClass)

    if __name__ == '__main__':
    parent_conn, child_conn = Pipe() # I added this
    manager = MyManager()
    manager.start()
    maths = manager.Maths()
    print maths.add(4, 3) # prints 7
    print maths.mul(7, 8) # prints 56
    maths.set(child_conn) # I added this, error is thrown here
    Metalone, Jan 6, 2010
    #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. Chris
    Replies:
    4
    Views:
    404
    Chris
    Sep 18, 2009
  2. Terry
    Replies:
    2
    Views:
    507
    Terry
    Sep 1, 2009
  3. Sebastien Binet
    Replies:
    4
    Views:
    862
    Sebastien Binet
    Dec 16, 2009
  4. Veloz
    Replies:
    1
    Views:
    296
  5. ichi
    Replies:
    0
    Views:
    270
Loading...

Share This Page