Check if a TCP port is open on the given host. Returns True if connection succeeds, False otherwise.
(host: str, port: int, timeout=1.0)
| 18 | |
| 19 | |
| 20 | def is_port_open(host: str, port: int, timeout=1.0): |
| 21 | """ |
| 22 | Check if a TCP port is open on the given host. |
| 23 | Returns True if connection succeeds, False otherwise. |
| 24 | """ |
| 25 | try: |
| 26 | with socket.create_connection((host, port), timeout): |
| 27 | return True |
| 28 | except Exception: |
| 29 | return False |
| 30 | |
| 31 | |
| 32 | def _clean_cuda_process(): |
no outgoing calls