Retrieve the active server port
masterIf you use port=0 to let the server select a free port, you can find the active port using these methods:
- Console Output: The address and port are printed to the console on startup.
- Port File: Provide a
port_filepath during initialization. The server writes the port to this file and removes it when stopped. activate()method: Callingserver.activate()returns the bound port and sets internal attributes.- Attributes: Access
server.server_address(a tuple of address and port) orserver.server_port(the port as an integer).