[zeromq-dev] Passing a python object (PyZMQ)

Arnaud Loonstra arnaud at sphaero.org
Tue Jun 9 10:32:05 CEST 2015

On 06/08/2015 08:10 PM, MinRK wrote:
> On Mon, Jun 8, 2015 at 11:00 AM, Arnaud Loonstra <arnaud at sphaero.org
> <mailto:arnaud at sphaero.org>> wrote:
>     A python dictionary is not thread safe, AFAIK. So if multiple
>     producers(threads) write to the dictionary you'll run into trouble.
> Depends what you mean. All of Python is threadsafe, thanks to the GIL.
> Since object IDs are unique as long as the objects exist, you should
> have no collisions putting different objects in the dictionary from
> different threads. You could also key by UUID if for some reason you
> have multiple threads sending the same exact object.
> -MinRK

You could be right indeed. To operate on the dictionary only one GIL 
lock needs te be acquired since it is a native type. Then indeed you can 
share a single dictionary.

w: http://www.sphaero.org
t: http://twitter.com/sphaero
g: http://github.com/sphaero
i: freenode: sphaero_z25

More information about the zeromq-dev mailing list