-
-
Save MetroWind/5697a68fdf56e7f3f9f6 to your computer and use it in GitHub Desktop.
Make multiprocessing work with methods #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make multiprocessing work with methods. Add this to the beginning of file. | |
if sys.version_info.major == 2: | |
import copy_reg as CReg | |
else: | |
import copyreg as CReg | |
import types | |
def _reduce_method(m): | |
if m.im_self is None: | |
return getattr, (m.im_class, m.im_func.func_name) | |
else: | |
return getattr, (m.im_self, m.im_func.func_name) | |
CReg.pickle(types.MethodType, _reduce_method) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment