嗨 StackOverflow 的好人。
我正在使用 pyzmq 并且我有一些长时间运行的进程,这导致发现套接字句柄处于打开状态。我已将有问题的代码缩小到以下内容:
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 版本为 pyzmq-13.1.0
要么 pyzmq 中存在错误,要么我做错了什么。我希望你能帮帮我!!
谢谢!