[prev in list] [next in list] [prev in thread] [next in thread]
List: zeromq-dev
Subject: Re: [zeromq-dev] Is there a non-blocking alternative to Poller.poll() ?
From: David Jelenc <david.jelenc () fri ! uni-lj ! si>
Date: 2021-05-04 13:06:16
Message-ID: 87im3ytzqv.fsf () fri ! uni-lj ! si
[Download RAW message or body]
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 <matthieu.robert@irisa.fr> 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
> zeromq-dev@lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic