Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(socket-buffer): set hwm and buffer limit for zmq socket
Browse files Browse the repository at this point in the history
  • Loading branch information
felix committed Sep 19, 2019
1 parent 6e87afa commit 4f38944
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gnes/service/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4f38944

Please sign in to comment.