Skip to content
Snippets Groups Projects

Deliver notification info

Merged Adham Hashibon requested to merge deliver-to-ui into master
2 files
+ 23
12
Compare changes
  • Side-by-side
  • Inline
Files
2
import errno
import logging
from traits.api import Any, List
from force_bdss.api import BaseNotificationListener
@@ -5,17 +7,30 @@ import zmq
class UINotification(BaseNotificationListener):
#: The ZMQ context.
_context = Any()
#: The pubsub socket.
_pub_socket = Any()
#: The synchronization socket to recover already sent information at a
#: later stage
_rep_socket = Any()
#: The cache of messages as they are sent out.
_msg_cache = List()
def deliver(self, model, message):
try:
data = self._rep_socket.recv(flags=zmq.NOBLOCK)
except zmq.ZMQError:
pass
else:
except zmq.ZMQError as e:
if e.errno == errno.EAGAIN:
data = None
else:
logging.error("Error while receiving data from "
"reply socket: {}".format(str(e)))
if data and data[0:4] == "SYNC".encode("utf-8"):
self._rep_socket.send_multipart(self._msg_cache)
msg = "ACTION {}".format(message).encode("utf-8")
Loading