[issue28965] Multiprocessing spawn/forkserver fails to pass Queues

Sean Murphy report at bugs.python.org
Tue Dec 13 19:51:48 EST 2016


New submission from Sean Murphy:

Python fails to pass a Queue when calling Process with multiprocessing.set_start_method set to "spawn" or "forkserver".

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/multiprocessing/spawn.py", line 106, in spawn_main
    exitcode = _main(fd)
  File "/usr/lib/python3.5/multiprocessing/spawn.py", line 116, in _main
    self = pickle.load(from_parent)
  File "/usr/lib/python3.5/multiprocessing/synchronize.py", line 111, in __setstate__
    self._semlock = _multiprocessing.SemLock._rebuild(*state)
FileNotFoundError: [Errno 2] No such file or directory


Here is a minimized example:
```
#!/usr/bin/env python3

import multiprocessing

def check_child(q):
    print("Queue", q)


if __name__ == '__main__':
    multiprocessing.set_start_method('spawn')
    # multiprocessing.set_start_method('fork')
    # multiprocessing.set_start_method('forkserver')

    q = multiprocessing.Queue(-1)
    print("q", q)

    proc = multiprocessing.Process(target=check_child, args=(q,))
    proc.start()
```

Also, this fails when the Queue is implicitly passed to the child.
```
class Blerg():
    def __init__(self):
        self.q = multiprocessing.Queue(-1)

    def print_queue(self):
        print("Queue", self.q)


if __name__ == '__main__':
    multiprocessing.set_start_method('spawn')

    blerg = Blerg()

    blerg.print_queue()

    proc = multiprocessing.Process(target=blerg.print_queue)
    proc.start()
```

$ python3 --version
Python 3.5.2

Windows (which defaults to "spawn" style multiprocessing) does not seem to have this issue (at least in 2.7.12).

----------
components: Library (Lib)
messages: 283150
nosy: Sean Murphy
priority: normal
severity: normal
status: open
title: Multiprocessing spawn/forkserver fails to pass Queues
type: crash
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28965>
_______________________________________


More information about the Python-bugs-list mailing list