[zeromq-dev] czmq python binding Zpoller

Johan Philips johan.philips at kuleuven.be
Thu Nov 5 14:53:32 CET 2015

> On 05 Nov 2015, at 22:20, Arnaud Loonstra <arnaud at sphaero.org> wrote:
> On 2015-11-05 02:50, Johan Philips wrote:
>> How can I get the actual socket out of it, because Zpoller seems to
>> return a c_void_p which I cannot compare to my Zsock object I added 
>> to
>> the poller.
>> Minimal example using zyre nodes:
>> Python 2.7.9 (default, Apr  2 2015, 15:33:21)
>> [GCC 4.9.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more 
>> information.
>>>>> from zyre import Zyre
>>>>> from czmq import Zsock, Zpoller
>>>>> n1 = Zyre("n1")
>>>>> n2 = Zyre("n2")
>>>>> n1.start()
>> 0
>>>>> n2.start()
>> 0
>>>>> poller = Zpoller(n1.socket(),n2.socket(), None)
>>>>> sock = poller.wait(100)
>>>>> print sock
>> c_void_p(27301232)
>>>>> print n1.socket(), n2.socket()
>> <czmq.Zsock object at 0x7fbd0968cfd0> <czmq.Zsock object at 
>> 0x7fbd0968cfd0>
>> Do I need to add cast or POINTER or is there a more convenient way?
>> Zsock(result, True) does not work since it will create a new object.
>> Thanks!
>> Johan
> I haven't found the best approach yet. First of all you can use 
> ZyreEvents. See the test.py file for an example.

I’ve been using ZyreEvent but since it’s blocking I need a working Zpoller :(

> I've used the zyre binding with PyZMQ. I had to wrap the binding to 
> cast the pointer to a PyZMQ socket object. I don't have the code here so 
> can't provide how it is done. I might have posted it on this ML though.

Ok, I’ll look into that. We were experiencing some odd behaviour with Pyre that’s why I switched to the binding provided in Zyre. I’ll see if I can combine this with PyCZMQ, which used ffi, rather than the python binding in czmq, which using ctypes.

> I haven't used CZMQ for this.... yet. I'd need to look into this.


> Perhaps some else knows a better way because indeed it is essential.
> Rg,
> Arnaud


> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

More information about the zeromq-dev mailing list