Check if a port is in use (cross-platform)
(port: int)
| 124 | |
| 125 | |
| 126 | def is_port_in_use(port: int) -> bool: |
| 127 | """Check if a port is in use (cross-platform)""" |
| 128 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: |
| 129 | return s.connect_ex(("localhost", port)) == 0 |
| 130 | |
| 131 | |
| 132 | def kill_process_on_port(port: int): |
no outgoing calls
no test coverage detected