Hi Matthieu,

yes there is. You can use AsyncIO, Tornado's IOLoop or gevent library. You can find more information here:
 https://pyzmq.readthedocs.io/en/latest/eventloop.html

Best,
David

Matthieu Robert <[email protected]> writes:

Hi ,

I picked up a Python project linking 3 components together using zeromq messages. Basically there is a Client sending and receiving message to/from an Orchestrator which also sends and receives messages to/from a Server.

The in-between component, the orchestrator, has a zmq.Poller object to which the server and client sockets are connected. To read the messages received on this Poller, I am using a while loop which basically does :

while(True) :
events = dict(Poller.poll(1))
#treat events ...

Previously the Poller.poll timeout parameter was set to 100 milliseconds but it was slowing down my program, afterwards I set the timeout to 1 millisecond and it significantly accelerated my program, but I still want to reduce its CPU usage by replacing all busy-waiting parts of my program (for example the while loop to request the Poller.poll(1)). And I don't want to use Poller.poll() without timeout because it blocks the program. I though of calling Poller.poll() in a thread in background, that would trigger the functions treating the events while my main orchestrator program was still doing its thing.

I was wondering if there was a non-blocking way, using zeromq, to be notified when the Poller receives a new event ? Instead of using a while loop to call Poller.poll(1) multiple times.

Thank you,

Matthieu Robert

_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to