提交 47cad02d 编写于 作者: L Lukáš Doktor

avocado.utils.network: Fix pylint issues

Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 24616a50
......@@ -38,7 +38,7 @@ def is_port_free(port, address):
:param port: Port number
:param address: Socket address to bind or connect
"""
s = None
sock = None
if address == "localhost":
protocols = PROTOCOLS
else:
......@@ -48,22 +48,22 @@ def is_port_free(port, address):
for family in FAMILIES:
for protocol in protocols:
try:
s = socket.socket(family, protocol)
sock = socket.socket(family, protocol)
if address == "localhost":
s.bind(("", port))
sock.bind(("", port))
else:
s.connect((address, port))
sock.connect((address, port))
return False
except socket.error as exc:
if exc.errno in (93, 94): # Unsupported combinations
continue
if address == "localhost":
return False
s.close()
sock.close()
return True
finally:
if s is not None:
s.close()
if sock is not None:
sock.close()
def find_free_port(start_port=1024, end_port=65535, address="localhost", sequent=True):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册