Paul Moore <p.f.mo...@gmail.com> added the comment:

For me, I headed straight for "Sharing state between processes" and the "Shared 
memory" object. That's probably because I was reviewing someone else's code, 
rather than writing my own, but nevertheless when coding I do tend to dive 
straight for the section that describes what I want to do, and miss "overview" 
type discussions.

The way the shared memory object is described, it reads that it is just that - 
shared. And so I'd assume that if a shared memory object is in multiple 
processes in a pool, it would be the *same* shared memory region, and the value 
would be accessible from all the processes.

>From there, for me at least, it's easy to proceed to the mistake of thinking 
>that the global initialisation of the x and y variables creates the *same* 
>shared memory objects in each process in the pool. Clearly it doesn't, hence 
>this is "not a bug" but for me it's an easy mistake to make.

Maybe it would be enough just to add a comment to the shared memory object 
documentation that said "every shared memory object is independent - there is 
no way to create a reference to the same shared memory object in multiple 
processes, instead you need to create the object in one process and pass it to 
all of the others". That would probably have made me stop and think long enough 
to not make the mistake I did.

----------

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

Reply via email to