Signals from WSGI Application and Server

The WSGI application entry point (wsgi_application) and the main lback.core.server.Server class are crucial components in the application’s lifecycle, handling incoming requests and managing the server. They emit signals at various stages, providing comprehensive hooks for monitoring server health, tracking request flow, handling initialization errors, and integrating with external logging and performance measurement tools.

Signal Name

Description

Arguments (kwargs)

wsgi_application_error

Emitted when the WSGI application encounters a critical error preventing request processing, typically due to core framework components not being initialized.

sender (str): Always “wsgi_application”.<br>``error_type`` (str): Describes the type of initialization error (e.g., “core_components_not_initialized”).<br>``environ`` (Dict`[:py:class:`str, Any]): The WSGI environment dictionary.

server_request_received

Emitted immediately after a new request is received by the WSGI application, before any significant processing begins (e.g., Request object creation).

sender (str): Always “wsgi_application”.<br>``method`` (str): The HTTP method of the request.<br>``path`` (str): The URL path of the request.<br>``full_path`` (str): The full path including query string.<br>``headers`` (Dict`[:py:class:`str, str]): A dictionary of HTTP request headers.<br>``environ`` (Dict`[:py:class:`str, Any]): The raw WSGI environment dictionary.

server_request_finished

Emitted at the very end of the WSGI application’s request processing, just before the final response is returned to the WSGI server. Includes performance metrics.

sender (str): Always “wsgi_application”.<br>``method`` (str): The HTTP method of the request.<br>``path`` (str): The URL path of the request.<br>``full_path`` (str): The full path including query string.<br>``duration`` (float): The total time taken to process the request in seconds.<br>``status_code`` (int or str): The HTTP status code of the final response (or ‘N/A’ if unavailable).<br>``response`` (Response, optional): The final response object generated.<br>``request`` (Request, optional): The request object that was processed.