Commit ebeac211 authored by Jérome Perrin's avatar Jérome Perrin

ooo/util: close sockets in socketStatus

parent a77f5599
......@@ -28,6 +28,7 @@
#
##############################################################################
import contextlib
from socket import socket, error
from errno import EADDRINUSE
from time import sleep
......@@ -47,7 +48,8 @@ def removeDirectory(path):
def socketStatus(hostname, port):
"""Verify if the address is busy."""
try:
socket().bind((hostname, port),)
with contextlib.closing(socket()) as sock:
sock.bind((hostname, port))
# False if the is free
return False
except error as err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment