mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:56:29 +00:00
added better logging to python
add day / winter / night switcher
This commit is contained in:
@@ -14,7 +14,8 @@ cdef class RemoteCommandHandler:
|
||||
self._router.setsockopt(zmq.LINGER, 0)
|
||||
with open(<str>constants.CONFIG_FILE, "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
self._router.bind(f'tcp://*:{config["zmq_port"]}')
|
||||
port = config["zmq_port"]
|
||||
self._router.bind(f'tcp://*:{port}')
|
||||
|
||||
self._dealer = self._context.socket(zmq.DEALER)
|
||||
self._dealer.setsockopt(zmq.LINGER, 0)
|
||||
@@ -30,6 +31,7 @@ cdef class RemoteCommandHandler:
|
||||
for _ in range(4): # 4 worker threads
|
||||
worker = Thread(target=self._worker_loop, daemon=True)
|
||||
self._workers.append(worker)
|
||||
print(f'Listening to commands on port {port}...')
|
||||
|
||||
cdef start(self):
|
||||
self._proxy_thread.start()
|
||||
@@ -60,7 +62,7 @@ cdef class RemoteCommandHandler:
|
||||
client_id, message = worker_socket.recv_multipart()
|
||||
cmd = RemoteCommand.from_msgpack(<bytes> message)
|
||||
cmd.client_id = client_id
|
||||
print(f'Received [{cmd}] from the client {client_id}')
|
||||
constants.log(<str>f'{cmd}', client_id)
|
||||
self._on_command(cmd)
|
||||
except Exception as e:
|
||||
if not self._shutdown_event.is_set():
|
||||
@@ -74,7 +76,7 @@ cdef class RemoteCommandHandler:
|
||||
with self._context.socket(zmq.DEALER) as socket:
|
||||
socket.connect("inproc://backend")
|
||||
socket.send_multipart([client_id, data])
|
||||
print(f'{len(data)} bytes was sent to client {client_id}')
|
||||
constants.log(<str>f'Sent {len(data)} bytes.', client_id)
|
||||
|
||||
cdef stop(self):
|
||||
self._shutdown_event.set()
|
||||
|
||||
Reference in New Issue
Block a user