classification
Title: from multiprocessing.pool import Pool bug on linux
Type: behavior Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jnoller, josh.r, sbt
Priority: normal Keywords:

Created on 2016-05-02 09:48 by 859911096, last changed 2016-05-03 06:26 by SilentGhost. This issue is now closed.

Files
File name Uploaded Description Edit
pool.py 859911096, 2016-05-02 09:48 a Pool code
Messages (3)
msg264637 - (view) Author: yangming (859911096) Date: 2016-05-02 09:48
When my code run on windows,it's right,but on linux,id(q) print same RAM address.
msg264638 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2016-05-02 11:47
This has nothing to do with Argument Clinic, which is an internal tool used in the Python 3.x series.
msg264668 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2016-05-02 20:45
The Queue module (queue on Py3) is for communication between threads, not processes; what you've written wouldn't behave correctly on any version of Python. You want to use multiprocessing's Queue class, not Queue.Queue, and to avoid possible deadlocks, you want to populate it after the pool workers are running.

In any event, id(q) is expected to match on Linux, which has fork semantics (so the memory space in parent and child is initially identical). On Windows it differs because spawn based multiprocessing means the objects are recreated in the child processes, rather than inherited directly.

This is a problem with your code and understanding on forking, not a problem in Python.
History
Date User Action Args
2016-05-03 06:26:21SilentGhostsetstatus: open -> closed
resolution: not a bug
stage: resolved
2016-05-02 20:45:06josh.rsetnosy: + josh.r
messages: + msg264668
2016-05-02 15:03:14SilentGhostsetnosy: + jnoller, sbt, - larry
type: behavior
2016-05-02 11:47:19larrysetnosy: - 859911096
messages: + msg264638
components: - Argument Clinic
2016-05-02 09:48:14859911096create