Fix unclean shutdown of ZMQ (#11740)

This commit is contained in:
Jason Hunter 2024-06-04 08:39:34 -04:00 committed by GitHub
parent ea0292b911
commit 7917bf55ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,9 +26,8 @@ class DetectionProxyRunner(threading.Thread):
def run(self) -> None:
"""Run the proxy."""
control = self.context.socket(zmq.SUB)
control = self.context.socket(zmq.REP)
control.connect(SOCKET_CONTROL)
control.setsockopt_string(zmq.SUBSCRIBE, "")
incoming = self.context.socket(zmq.XSUB)
incoming.bind(SOCKET_PUB)
outgoing = self.context.socket(zmq.XPUB)
@ -46,13 +45,13 @@ class DetectionProxy:
def __init__(self) -> None:
self.context = zmq.Context()
self.control = self.context.socket(zmq.PUB)
self.control = self.context.socket(zmq.REQ)
self.control.bind(SOCKET_CONTROL)
self.runner = DetectionProxyRunner(self.context)
self.runner.start()
def stop(self) -> None:
self.control.send_string("TERMINATE") # tell the proxy to stop
self.control.send("TERMINATE".encode()) # tell the proxy to stop
self.runner.join()
self.context.destroy()