Skip to content

Commit

Permalink
dev(hansbug): try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HansBug committed Dec 12, 2024
1 parent 1deea56 commit 271588f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hbutils/system/network/telnet_.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ def telnet(host, port: int, timeout: float = 5.0) -> bool:
sock = None
try:
sock = socket.create_connection((host, port), timeout)
return True
finally:
if sock is not None:
if sock:
sock.close()
except (ConnectionRefusedError, socket.timeout):
# ConnectionRefusedError is for Linux and macOS
# socket.timeout is for Windows
return False
else:
return True


def wait_for_port_online(host, port: int, timeout: Optional[float] = 5, interval: float = 0.3):
Expand Down

0 comments on commit 271588f

Please sign in to comment.