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

M

Metalone

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,588
Members
45,099
Latest member
AmbrosePri
Top