pyzmq
pyzmq copied to clipboard
Should I use asyncIO for subscriber socket or run subscriber socket in a different thread
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.
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.
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.