[issue33884] [multiprocessing] Multiprocessing in spawn mode doesn't work when the target is a method in a unittest.TestCase subclass, when run either with unittest or with pytest

2018-06-17 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

While this is limitation of the spawn and forkserver modes, I don't see how 
this is a bug.  Also, as you point out, making the method a classmethod or 
staticmethod works around the limitation.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> pending

___
Python tracker 

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



[issue33884] [multiprocessing] Multiprocessing in spawn mode doesn't work when the target is a method in a unittest.TestCase subclass, when run either with unittest or with pytest

2018-06-17 Thread Ned Deily


Change by Ned Deily :


--
nosy: +davin, pitrou

___
Python tracker 

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



[issue33884] [multiprocessing] Multiprocessing in spawn mode doesn't work when the target is a method in a unittest.TestCase subclass, when run either with unittest or with pytest

2018-06-17 Thread Yoni Rozenshein


New submission from Yoni Rozenshein :

multiprocessing will attempt to pickle things using ForkingPickler when 
starting a new process in spawn mode (in Windows this is the only mode, in 
Linux this is a non-default but settable mode).

When run within the context of a unit test, if it has to pickle a TestCase 
subclass, it encounters objects that can't be pickled. The attached file shows 
a minimum working example (uncomment the two commented lines under __main__ to 
run with pytest).

When run with unittest.main(), it raises:

TypeError: cannot serialize '_io.TextIOWrapper' object

When run with pytest.main(), it raises:

AttributeError: Can't pickle local object 
'ArgumentParser.__init__..identity'

Note that changing the _child_process in my example to a 
classmethod/staticmethod or moving it to a top-level function outside the class 
works around this issue (both with unittest and with pytest).

--
components: Library (Lib)
files: mp_pickle_issues.py
messages: 319811
nosy: Yoni Rozenshein
priority: normal
severity: normal
status: open
title: [multiprocessing] Multiprocessing in spawn mode doesn't work when the 
target is a method in a unittest.TestCase subclass, when run either with 
unittest or with pytest
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file47645/mp_pickle_issues.py

___
Python tracker 

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