New submission from Bala FA <barum...@redhat.com>: 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) ---------- components: Interpreter Core messages: 166299 nosy: Bala.FA priority: normal severity: normal status: open title: multiprocess fails to re-raise exception which has mandatory arguments type: crash versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15440> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com