[issue15440] multiprocess fails to re-raise exception which has mandatory arguments

2013-11-11 Thread Richard Oudkerk

Richard Oudkerk added the comment:

This was fixed for 3.3 in #1692335.

The issue of backporting to 2.7 is discussed in #17296.

--
resolution:  -> duplicate
status: open -> closed
superseder:  -> Cannot unpickle classes derived from 'Exception'
type: crash -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15440] multiprocess fails to re-raise exception which has mandatory arguments

2013-10-14 Thread Georg Brandl

Changes by Georg Brandl :


--
nosy: +sbt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15440] multiprocess fails to re-raise exception which has mandatory arguments

2012-07-24 Thread Bala FA

New submission from Bala FA :

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 
main()
  File "prod.py", line 61, in main
print myobj.fun3()
  File "", 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)', , ())

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=('', 5), 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=('', 5), 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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com