zmq tweaks

This commit is contained in:
ed 2025-01-25 11:29:38 +00:00
parent b8b5214f44
commit 5967c421ca

View file

@ -3519,18 +3519,21 @@ def _zmq_hook(
if mode == "pub": if mode == "pub":
sck = ctx.socket(zmq.PUB) sck = ctx.socket(zmq.PUB)
sck.setsockopt(zmq.LINGER, 0)
sck.bind(uri) sck.bind(uri)
time.sleep(1) # give clients time to connect; avoids losing first msg time.sleep(1) # give clients time to connect; avoids losing first msg
elif mode == "push": elif mode == "push":
sck = ctx.socket(zmq.PUSH) sck = ctx.socket(zmq.PUSH)
sck.bind(uri)
if timeout: if timeout:
sck.SNDTIMEO = int(timeout * 1000) sck.SNDTIMEO = int(timeout * 1000)
sck.setsockopt(zmq.LINGER, 0)
sck.bind(uri)
elif mode == "req": elif mode == "req":
sck = ctx.socket(zmq.REQ) sck = ctx.socket(zmq.REQ)
sck.connect(uri)
if timeout: if timeout:
sck.RCVTIMEO = int(timeout * 1000) sck.RCVTIMEO = int(timeout * 1000)
sck.setsockopt(zmq.LINGER, 0)
sck.connect(uri)
else: else:
raise Exception() raise Exception()