aio-libs / aiozmq

Asyncio (pep 3156) integration with ZeroMQ
aiozmq.readthedocs.org
BSD 2-Clause "Simplified" License
422 stars 56 forks source link

How to flush a transmit buffer? #190

Open amaitra opened 1 year ago

amaitra commented 1 year ago

I have a simple pub-sub application. The pub publishes events, expects the subs to work on them and respond back. The pub waits for subs to complete their actions (variable time) or times out (outside scope of zmq).

I frequently find the sub receives a message, puts out a response (on a separate message channel) but the pub process does not receive it until much later. Sometimes in fact after a timeout in the pub which moves on (state machine). But it is always received - mostly on a close from the subscriber end.

I do not want to block on every message - but in certain cases, I want it. I want the equivalent of fflush(fd) - pushes it out so that it is in the receivers queue. The CPU may be busy in some of these intervals (that is when this tends to happen). The time out is in the order of 5 seconds - long time in a server class CPU.

Both pub-sub entities are running on a single system (no network).

There does not seem to be a way to set up the socket that way? Or flush it on demand. Or am I missing something?