Skip to content
Permalink
Browse files

fix(socket-buffer): set hwm and buffer limit for zmq socket

  • Loading branch information...
numb3r3 committed Sep 19, 2019
1 parent 6e87afa commit 4f3894496a01f00147bac82385ef150779942304
Showing with 8 additions and 0 deletions.
  1. +8 −0 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()

0 comments on commit 4f38944

Please sign in to comment.
You can’t perform that action at this time.