ThreadedWSGIServer
A threaded version of the WSGIServer
Attributes
| Attribute | Type | Description |
|---|---|---|
| daemon_threads | boolean = True | Determines whether the server threads are created as daemon threads, allowing the main program to exit even if threads are still active. |
Constructor
Signature
def ThreadedWSGIServer(
*args: any,
connections_override: dict = None,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| *args | any | Variable length argument list passed to the parent WSGIServer constructor. |
| connections_override | dict = None | A dictionary of database connections to be used by request threads. |
| **kwargs | any | Arbitrary keyword arguments passed to the parent WSGIServer constructor. |
Methods
process_request_thread()
@classmethod
def process_request_thread(
request: socket,
client_address: tuple
)
Handles an individual HTTP request within a dedicated thread, optionally overriding database connections with those provided by the parent thread.
Parameters
| Name | Type | Description |
|---|---|---|
| request | socket | The socket object used to communicate with the client for this specific request |
| client_address | tuple | A tuple containing the IP address and port of the client that initiated the request |
Returns
| Type | Description |
|---|---|
| Nothing is returned; the method executes the request handling logic in the current thread. |
close_request()
@classmethod
def close_request(
request: socket
)
Finalizes the request by closing all thread-local database connections before invoking the standard socket teardown procedures.
Parameters
| Name | Type | Description |
|---|---|---|
| request | socket | The socket object representing the client connection that is being terminated |
Returns
| Type | Description |
|---|---|
| Nothing is returned. |