From 88cb238c60d8a42236fd010c50af8728c9fc22bc Mon Sep 17 00:00:00 2001 From: Vishal Date: Wed, 12 Sep 2018 09:53:16 -0400 Subject: [PATCH] wait_server_available method ... Move the socket.socket() initialization to be inside the while loop. Having it outside initiates it only once and when closed inside the while loop, it starts to raise 'Bad File Descriptor' error since the socket is closed. --- vibora/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vibora/utils.py b/vibora/utils.py index 83c70b8..16d13b7 100644 --- a/vibora/utils.py +++ b/vibora/utils.py @@ -131,9 +131,12 @@ def wait_server_available(host: str, port: int, timeout: int=10) -> None: :param port: TCP port used to connect. :return: """ - sock = socket.socket() - sock.settimeout(timeout) while timeout > 0: + """ Start of change """ + sock = socket.socket() + sock.settimeout(timeout) + """ End of change """ + start_time = time.time() try: sock.connect((host, port))