这是代码,
def get_local_ip():
try:
# doesn't even have to be reachable
s.connect(('10.255.255.255', 1))
ip = s.getsockname()[0]
except Exception as err:
ip = '127.0.0.1'
finally:
s.close()
return ip
我收到OSError:文件过多错误,如果我在wsgi服务器中调用此函数。我不太确定为什么会这样,因为我要关闭Socket。