From 4f3894496a01f00147bac82385ef150779942304 Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 19 Sep 2019 15:02:26 +0800 Subject: [PATCH] fix(socket-buffer): set hwm and buffer limit for zmq socket --- gnes/service/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gnes/service/base.py b/gnes/service/base.py index 18333445..4c5b3512 100644 --- a/gnes/service/base.py +++ b/gnes/service/base.py @@ -129,6 +129,12 @@ def build_socket(ctx: 'zmq.Context', host: str, port: int, socket_type: 'SocketT sock.setsockopt(zmq.SUBSCRIBE, identity.encode('ascii') if identity else b'') # sock.setsockopt(zmq.SUBSCRIBE, b'') + sock.setsockopt(zmq.RCVHWM, 100) + sock.setsockopt(zmq.RCVBUF, 512 * 1024 * 1024) # network buffer 512M + + sock.setsockopt(zmq.SNDHWM, 100) + sock.setsockopt(zmq.SNDBUF, 512 * 1024 * 1024) + return sock, sock.getsockopt_string(zmq.LAST_ENDPOINT) @@ -423,6 +429,8 @@ def _run(self, ctx): self.logger.info('break from the event loop') except ComponentNotLoad: self.logger.error('component can not be correctly loaded, terminated') + except Exception as e: + self.logger.error("exception occured", exc_info=True) finally: self.is_ready.set() self.is_event_loop.clear()