duck.http.core.httpd.serversยถ
Module containing server classes.
Module Contentsยถ
Classesยถ
HTTPServer class for handling requests. |
|
MicroHTTPServer class. |
Dataยถ
APIยถ
- duck.http.core.httpd.servers.BaseServerยถ
None
- class duck.http.core.httpd.servers.HTTPServer(addr: Tuple[str, int], application: Union[App, MicroApp], domain: str = None, uses_ipv6: bool = False, enable_ssl: bool = False, ssl_params: Optional[Dict] = None, no_logs: bool = False, workers: Optional[int] = None, force_worker_processes: bool = False)ยถ
Bases:
duck.http.core.httpd.servers.BaseServerHTTPServer class for handling requests.
Initialization
Initialise the server instance.
- Parameters:
addr โ Tuple of address and port.
application โ The application that is using this server. Can be either duck main app or micro app.
domain โ The server domain.
uses_ipv6 โ Whether If the server is on (IPV6)
enable_ssl โ Whether to enable
HTTPS.ssl_params โ Dictionary containing ssl parameters to parse to SSLSocket. If None, default ones will be used.
no_logs โ Whether to disable logging.
workers โ Number of workers to use. None will disable workers.
force_worker_processes โ
Determines whether to use worker processes instead of the default worker threads. By default, when
workersis greater than 1, the server will use worker threads. Threads avoid cross-process synchronization issuesโsuch as component registry mismatches (e.g., issues with Lively components) that occur when state lives in separate processes.Set this flag to
Trueonly when process isolation is explicitly desired and you do not require shared in-memory synchronization between workers.
- __instances: intยถ
0
This is the current number of server instances.
- reload_ssl_context() boolยถ
Reloads only the SSL certificate and key files. Keeps the base context (protocols, ciphers, etc.) intact.
- Raises:
RuntimeError โ If
_ssl_contextis not set andssl_wrap_sockethas already been used.Exception โ Any other exception on error.
- Returns:
Whether reload has actually been performed.
- Return type:
bool
โฆ admonition:: Notes
This does nothing if
_ssl_contextnot set.
- ssl_wrap_socket(client_socket: socket.socket) duck.utils.xsocket.ssl_xsocketยถ
Wraps client socket with SSL context.
- class duck.http.core.httpd.servers.MicroHTTPServer(addr: Tuple[str, int], microapp: MicroApp, domain: str = None, uses_ipv6: bool = False, enable_ssl: bool = False, ssl_params: bool = None, no_logs: bool = True, workers: Optional[int] = None, force_worker_processes: bool = False)ยถ
Bases:
duck.http.core.httpd.httpd.BaseMicroServer,duck.http.core.httpd.servers.HTTPServerMicroHTTPServer class.
Initialization
Initialise the server instance.
- Parameters:
addr โ Tuple of address and port.
application โ The application that is using this server. Can be either duck main app or micro app.
domain โ The server domain.
uses_ipv6 โ Whether If the server is on (IPV6)
enable_ssl โ Whether to enable
HTTPS.ssl_params โ Dictionary containing ssl parameters to parse to SSLSocket. If None, default ones will be used.
no_logs โ Whether to disable logging.
workers โ Number of workers to use. None will disable workers.
force_worker_processes โ
Determines whether to use worker processes instead of the default worker threads. By default, when
workersis greater than 1, the server will use worker threads. Threads avoid cross-process synchronization issuesโsuch as component registry mismatches (e.g., issues with Lively components) that occur when state lives in separate processes.Set this flag to
Trueonly when process isolation is explicitly desired and you do not require shared in-memory synchronization between workers.