Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use zmq.NOBLOCK for AsyncFetcher. #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions ami/flowchart/library/DisplayWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,37 @@ def update_topics(self, topics, terms):
self.sockets[name] = (sock, count+1)

def run(self):

while self.running:
for sock, flag in self.poller.poll():
if flag != zmq.POLLIN:
continue
if sock == self.recv_interrupt and sock.recv_pyobj():
break
topic = sock.recv_string()
topic = topic.rstrip('\0')
heartbeat = sock.recv_pyobj()
reply = sock.recv_serialized(self.deserializer, copy=False)

limit = 10

while True:
count = 0
topic = None
heartbeat = None
reply = None
while count < limit:
try:
topic = sock.recv_string(flags=zmq.NOBLOCK)
topic = topic.rstrip('\0')
heartbeat = sock.recv_pyobj(flags=zmq.NOBLOCK)
reply = sock.recv_serialized(self.deserializer, copy=False, flags=zmq.NOBLOCK)
count += 1
except zmq.ZMQError as e:
if e.errno == zmq.EAGAIN:
break
else:
raise

if topic is not None:
break

self.data[self.view_subs[topic]] = reply
self.timestamps[self.view_subs[topic]] = heartbeat
# check if the data is ready
Expand Down