Hi good people of StackOverflow.
I'm using pyzmq and I've got some long-running processes, which led to a discovery that socket handles are being left open. I've narrowed the offending code down to the following:
import zmq
uri = 'tcp://127.0.0.1'
sock_type = zmq.REQ
linger = 250
# Observe output of lsof -p <pid> here and see no socket handles
ctx = zmq.Context.instance()
sock = ctx.socket(sock_type)
sock.setsockopt(zmq.LINGER, linger)
port = sock.bind_to_random_port(uri)
# Observe output of lsof -p <pid> here and see many socket handles
sock.close() # lsof -p <pid> still showing many socket handles
ctx.destroy() # Makes no difference
pyzmq version is pyzmq-13.1.0
Either there is a bug in pyzmq, or I'm doing something incorrectly. I hope you can help me!!
Thanks!