New submission from Max:

It seems both me and many other people (judging from SO questions) are confused 
about whether it's ok to write this:

from multiprocessing import Process, Queue
q = Queue()

def f():
    q.put([42, None, 'hello'])

def main():
    p = Process(target=f)
    p.start()
    print(q.get())    # prints "[42, None, 'hello']"
    p.join()

if __name__ == '__main__':
    main()

It's not ok (doesn't work on Windows presumably because somehow when it's 
pickled, the connection between global queues in the two processes is lost; 
works on Linux, because I guess fork keeps more information than pickle, so the 
connection is maintained).

I thought it would be good to clarify in the docs that all the Queue() and 
Manager().* and other similar objects should be passed as parameters not just 
defined as globals.

----------
assignee: docs@python
components: Documentation
messages: 289454
nosy: docs@python, max
priority: normal
severity: normal
status: open
title: Clarify how to share multiprocessing primitives
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29795>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to