Skip to main content

ThreadedWSGIServer

A threaded version of the WSGIServer

Attributes

AttributeTypeDescription
daemon_threadsboolean = TrueDetermines 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

NameTypeDescription
*argsanyVariable length argument list passed to the parent WSGIServer constructor.
connections_overridedict = NoneA dictionary of database connections to be used by request threads.
**kwargsanyArbitrary 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

NameTypeDescription
requestsocketThe socket object used to communicate with the client for this specific request
client_addresstupleA tuple containing the IP address and port of the client that initiated the request

Returns

TypeDescription
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

NameTypeDescription
requestsocketThe socket object representing the client connection that is being terminated

Returns

TypeDescription
Nothing is returned.