pyzmq icon indicating copy to clipboard operation
pyzmq copied to clipboard

Should I use asyncIO for subscriber socket or run subscriber socket in a different thread

Open yichong96 opened this issue 3 years ago • 2 comments

I am thinking of using zeroMQ sub socket to receive notifications from another service. The sub socket should not be blocking as the program has main code to run.

Should I run the socket in a while loop in a different thread ? or should I use async IO sockets.

yichong96 avatar Jan 05 '22 08:01 yichong96

I can't really answer that. Both approaches work, and it will depend on the rest of your application which fits better. It's up to you to choose the concurrency model that suits your application best.

minrk avatar Jan 10 '22 10:01 minrk

I have created a new library, https://pypi.org/project/aiowire/ - specifically for creating servers based on zmq.asyncio.Poller.

See #1650 for a full example.

frobnitzem avatar Feb 04 '22 17:02 frobnitzem