a little experiment with zmq polling

workspace
Brendan Howell 8 years ago
parent 7fa2deaa15
commit 2e561bbed9

@ -308,12 +308,21 @@ class Bureau(object):
# register commands and api methods # register commands and api methods
self._publish_methods() self._publish_methods()
poller = zmq.Poller()
poller.register(self._recv, zmq.POLLIN)
while True: while True:
try: try:
msg = self._recv.recv_string(flags=zmq.NOBLOCK) msgs = dict(poller.poll(500))
except zmq.ZMQError: if msgs:
time.sleep(0.05) # don't waste CPU if msgs.get(self._recv) == zmq.POLLIN:
continue msg = self._recv.recv_string(flags=zmq.NOBLOCK)
else:
continue
# msg = self._recv.recv_string(flags=zmq.NOBLOCK)
#except zmq.ZMQError:
# time.sleep(0.05) # don't waste CPU
# continue
try: try:
self.log.debug("got message:" + msg) self.log.debug("got message:" + msg)
dot = msg.find(".") dot = msg.find(".")

Loading…
Cancel
Save