duck.utils.port_registry¶
Utilities for tracking and validating occupied ports within Duck.
Module Contents¶
Classes¶
Registry for ports reserved or currently in use during Duck’s lifecycle. |
API¶
- class duck.utils.port_registry.PortRegistry[source]¶
Registry for ports reserved or currently in use during Duck’s lifecycle.
- _occupied_ports: dict[int, str]¶
None
Maps occupied ports to their registered occupier/source.
- classmethod get_port_occupier(port: int) str | None[source]¶
Return the occupier registered for a given port.
- Parameters:
port – Port number to resolve.
- Returns:
Registered occupier if found, otherwise None.
- classmethod is_port_occupied(port: int) bool[source]¶
Check whether a port is already registered as occupied.
- Parameters:
port – Port number to check.
- Returns:
True if the port is occupied, otherwise False.