This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Race condition on Multiprocessing module documentation
Type: Stage:
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: alejolp, benjamin.peterson, georg.brandl
Priority: normal Keywords:

Created on 2008-11-12 22:35 by alejolp, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg75804 - (view) Author: Alejandro Santos (alejolp) Date: 2008-11-12 22:35
The "devel" documentation of the "Multiprocessing" module at the
"Exchanging objects between processes" section has the following example
snippet:

from multiprocessing import Process, Queue

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

 if __name__ == '__main__':
     q = Queue()
     p = Process(target=f, args=(q,))
     p.start()
     print q.get()    # prints "[42, None, 'hello']"
     p.join()

The last two lines should be swapped to avoid a race condition:

     p.join()
     print q.get()    # prints "[42, None, 'hello']"

BTW, Nice work. Keep on going folks =)
msg75805 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-11-12 22:38
Why? The q.get() will block until an item is put on it.
msg75806 - (view) Author: Alejandro Santos (alejolp) Date: 2008-11-12 22:39
Ups. My mistake. Sorry
History
Date User Action Args
2022-04-11 14:56:41adminsetgithub: 48561
2008-11-12 23:13:25benjamin.petersonsetstatus: open -> closed
resolution: not a bug
2008-11-12 22:39:22alejolpsetmessages: + msg75806
2008-11-12 22:38:22benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg75805
2008-11-12 22:35:22alejolpcreate