> On Jun 8, 2015, at 01:35, Arnaud Loonstra <arn...@sphaero.org> wrote:
> 
>> On 06/06/2015 01:52 AM, MinRK wrote:
>> Without using ctypes, you could pass the objects through a namespace:
>> 
>> |# shared namespace
>> ns = {}
>> 
>> # sender
>> ns[id(obj)] = obj
>> pipe_out.send(struct.pack(b'Q',1))
>> 
>> # receiver
>> id_bytes = pipe_in.recv()
>> obj_id = struct.unpack(b'Q', id_bytes)[0]
>> obj = ns.pop(obj_id)
>> |
>> 
>> The ctypes cast approach doesn’t hold a reference to the object while
>> it’s in transit, so it’s possible for the restoration to fail if the
>> object has been garbage collected in between send/recv.
> 
> You're right I ended up doing something very similar to workaround early 
> garbage collection but this is much nicer. However it only works between 
> a producer and consumer thread, not more. So every producer thread needs 
> its own namespace.

I'm not sure why. You should only need one namespace per process.

-MinRK

> 
> Rg,
> 
> Arnaud
> -- 
> w: http://www.sphaero.org
> t: http://twitter.com/sphaero
> g: http://github.com/sphaero
> i: freenode: sphaero_z25
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to