classification
Title: Cannot pass a SyncManager proxy to a multiprocessing subprocess on Windows
Type: behavior Stage:
Components: Windows Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: davin, jjdmon, paul.moore, pitrou, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2018-03-16 18:10 by jjdmon, last changed 2018-03-16 20:08 by ned.deily.

Messages (1)
msg313964 - (view) Author: Jeff DuMonthier (jjdmon) Date: 2018-03-16 18:10
The following simple example code creates a started SyncManager and passes it as an argument to a subprocess started with multiprocessing.Process().  It works on Linux and Mac OS but fails on Windows.

import multiprocessing as mp

def subProcFn(m1):
    pass
    
if __name__ == "__main__":

    __spec__ = None
    
    m1 = mp.Manager()
    
    p1 = mp.Process(target=subProcFn, args=(m1,))
    p1.start()
    p1.join()

This is the traceback in Spyder:

runfile('D:/ManagerBug.py', wdir='D:')
Traceback (most recent call last):

  File "<ipython-input-1-534b9087bae9>", line 1, in <module>
    runfile('D:/ManagerBug.py', wdir='D:')

  File "...\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "...\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "D:/ManagerBug.py", line 22, in <module>
    p1.start()

  File "...\anaconda3\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)

  File "...\anaconda3\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)

  File "...\anaconda3\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)

  File "...\anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)

  File "...\anaconda3\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)

TypeError: can't pickle weakref objects
History
Date User Action Args
2018-03-16 20:08:00ned.deilysetnosy: + pitrou, davin
2018-03-16 18:10:26jjdmoncreate