The ports.py module#
Summary#
Find free ports on the localhost. |
Description#
Helpers for managing port assignment.
Module detail#
- ports.find_free_ports(num_ports: int = 1) list[int]#
Find free ports on the localhost.
Note
Because there is no way to reserve a port that would still allow a server to connect to it, there is no guarantee that the ports are still free when eventually used.
Parameters#
- num_ports :
Number of free ports to obtain.