espnet2.train.distributed_utils.free_port
Less than 1 minute
espnet2.train.distributed_utils.free_port
espnet2.train.distributed_utils.free_port()
Find a free port using bind().
This function attempts to find a free port by creating a socket and binding it to an available port. However, there is a possibility that the port may be occupied by another process after it has been found, as there is an interval between finding the port and using it. Thus, it is not guaranteed that the port is truly free at the time of usage.
- Returns: A free port number.
- Return type: int
Examples
>>> port = free_port()
>>> print(port) # Outputs a free port number