From 5a2b9983b691ec11364aadeda47deea8303c1b7a Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Mon, 16 Aug 2021 07:58:19 +0200 Subject: [PATCH] switch to classic API --- aman/com/Euroscope.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/aman/com/Euroscope.py b/aman/com/Euroscope.py index e595b2a..9255be6 100644 --- a/aman/com/Euroscope.py +++ b/aman/com/Euroscope.py @@ -7,9 +7,8 @@ import sys import threading import zmq -from zmq.asyncio import Context import zmq.auth -from zmq.auth.asyncio import AsyncioAuthenticator +from zmq.auth import Authenticator from aman.config import Server @@ -20,8 +19,15 @@ class ReceiverThread(threading.Thread): def run(self): try: + # create the poller to wait with a timeout to receive data + poller = zmq.Poller() + poller.register(self.socket, zmq.POLLIN) + while True: - True + # wait 1s to receive data + events = poller.poll(1000) + if self.socket in events and events[self.socket] == zmq.POLLIN: + msg = self.socket.recv() finally: return @@ -43,13 +49,13 @@ class Euroscope: # @brief Initializes the ZMQ socket # @param[in] config The server configuration def __init__(self, config : Server.Server): - self.context = Context.instance() + self.context = zmq.Context() # initialize the authentication module authLocation = ( str(config.ClientKeyPath) ) - self.auth = AsyncioAuthenticator(context = self.context) + self.auth = Authenticator(context = self.context) self.auth.configure_curve(domain='*', location = authLocation) self.auth.allow('127.0.0.1') self.auth.start()