[zeromq-dev] ZMQ_FD, missing events
sustrik at 250bpm.com
Wed Nov 30 12:28:58 CET 2011
Sounds like a 0MQ bug then. Can you possibly strip the test case down to
the minimal version that's able to reproduce the problem?
On 30/11/11 01:05, Francois-Xavier Bourlet wrote:
> Thanks for your fast answer.
> I am aware it's edge triggered. In fact my little test program is a
> copy paste of gevent-zeromq (hence the little link on the top of the
> code ;)). I just simplified a bit the code to put everything in one
> file for the sack of my example. Note that I get the same error in my
> RPC project using gevent-zeromq without modifying it in any way.
> On Tue, Nov 29, 2011 at 3:56 PM, MinRK<benjaminrk at gmail.com> wrote:
>> On Tue, Nov 29, 2011 at 15:36, Francois-Xavier Bourlet<fx at dotcloud.com>
>>> First, let me tell you how much we appreciate and use ZMQ here, at
>>> dotCloud. We have developed an RPC protocol/system based on ZMQ.
>>> System for which we have an implementation in Python and nodejs. Our
>>> whole platform communication exclusively pass trough ZMQ.
>>> We never had major issue with ZMQ, and everything was working well
>>> until... I tried to implement a Python Gevent version of our RPC
>>> First, some versions details:
>>> - linux platform x86_64
>>> - zmq>= 2.1.10 (git master as today
>>> - pyzmq == v22.214.171.124
>>> - gevent == 0.13.6
>>> - python 2.7
>>> I have a tiny wrapper around PythonZMQ to make it compliant with
>>> gevent (coroutine) style programming.
>>> To integrate ZMQ into the gevent mainloop, I am using the fd returned
>>> by getsockopt(ZMQ_FD) and sometimes the fd is never notified that the
>>> state (getsockopt(ZMQ_EVENTS)) of the socket changed. Hence my code is
>>> waiting infinitely.
>>> Code speak better than words: http://pastebin.com/r3tiywzb
>>> This code will run a simple pong server (REP) and an *asynchronous*
>>> client (DEALER/XREQ).
>>> The client will keep sending messages, and keep receive messages
>>> without taking care of any orders.
>>> When I run this program on my machine, after few second, the receiver
>>> part of the client block while waiting for some event about new
>>> message available, but the event was never fired. When this case
>>> happen the program exit with the following message: "here we go,
>>> nobody told me about new messages!"
>> Are you aware that the ZMQ_FD is edge-triggered, and not level-triggered?
>> That means that you must process *all* available events when the event is
>> If ≥2 recvs are waiting, and you only process one, then the POLLIN event
>> will never fire again, hence an infinite wait.
>> You might check out Travis Cline's gevent-zeromq, which is meant to take
>> care of exactly this.
>>> Thanks a lots for any help!
>>> Best Regards,
>>> François-Xavier Bourlet
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
More information about the zeromq-dev