Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zeromq zmq.Poller & stdin

Is it possible to use zmq.Poller to also poll for data availability on stdin? If not, what would be the most efficient wait to poll, at the some time (ideally), for data availability on zeromq sockets & stdin?

like image 974
jldupont Avatar asked Feb 25 '12 21:02

jldupont


1 Answers

yes, zmq pollers do support native FDs, including stdin, etc., so you just need to check sys.stdin.fileno():

poller = zmq.Poller()
poller.register(sys.stdin, zmq.POLLIN)
poller.register(mysocket, zmq.POLLIN)
evts = dict(poller.poll(1000))
stdin_ready = evts.get(sys.stdin.fileno(), False)
socket_ready = evts.get(mysocket, False)
like image 118
minrk Avatar answered Sep 24 '22 23:09

minrk