homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Bala.FA
Recipients Bala.FA
Date 2012年07月24日.15:17:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1343143072.3.0.822241372547.issue15440@psf.upfronthosting.co.za>
In-reply-to
Content
I use multiprocess in one of my project. When an exception which
requires mandatory argument is raised by a server process, is not
re-raised properly to client process. I get an error something like
below
Traceback (most recent call last):
 File "prod.py", line 69, in <module>
 main()
 File "prod.py", line 61, in main
 print myobj.fun3()
 File "<string>", line 2, in fun3
 File "/usr/lib64/python2.7/multiprocessing/managers.py", line 759,
in _callmethod
 kind, result = conn.recv()
TypeError: ('__init__() takes exactly 2 arguments (1 given)', <class
'__main__.MyException2'>, ())
However, if an exception which has optional argument is raised by
server process, is re-raised properly to client process.
Below is a reproducer.
#!/usr/bin/python
import sys
import os
import time
import subprocess
from multiprocessing.managers import BaseManager
class MyManager(BaseManager):
 pass
class MyException1(Exception):
 def __init__(self, msg=''):
 self.msg = msg
 def __str__(self):
 return self.msg
class MyException2(Exception):
 def __init__(self, msg):
 self.msg = msg
 def __str__(self):
 return self.msg
class MyClass(object):
 def fun1(self):
 return 'this is fun1'
 def fun2(self):
 raise MyException1('fun2 raised')
 def fun3(self):
 raise MyException2('fun3 raised')
def runManager():
 manager = MyManager(address=('', 50000), authkey='abc')
 manager.register('instance', callable=MyClass)
 server = manager.get_server()
 print "manager is running"
 server.serve_forever()
def startManager():
 p = subprocess.Popen(['python', __file__, 'manager'])
 time.sleep(1)
 return p
def main():
 p = startManager()
 manager = MyManager(address=('', 50000), authkey='abc')
 manager.register('instance')
 print "connecting to manager"
 manager.connect()
 myobj = manager.instance()
 print myobj.fun1()
 try:
 print myobj.fun2()
 except MyException1, e:
 print e
 try:
 print myobj.fun3()
 except MyException2, e:
 print e
 finally:
 p.kill()
if __name__ == '__main__':
 if len(sys.argv) == 1:
 main()
 else:
 runManager()
I use python 2.7.3 on fedora 17 on x86_64 (rpm version is
python-2.7.3-6.fc17.x86_64)
History
Date User Action Args
2012年07月24日 15:17:52Bala.FAsetrecipients: + Bala.FA
2012年07月24日 15:17:52Bala.FAsetmessageid: <1343143072.3.0.822241372547.issue15440@psf.upfronthosting.co.za>
2012年07月24日 15:17:51Bala.FAlinkissue15440 messages
2012年07月24日 15:17:50Bala.FAcreate

AltStyle によって変換されたページ (->オリジナル) /