Server implementation tools — Threads helper

Server implementation tools module for thread management.


Background Server Thread

class easynetwork.servers.threads_helper.NetworkServerThread

Bases: Thread

A Thread dedicated to network servers.

__init__(server: AbstractNetworkServer, group: None = None, name: str | None = None, *, daemon: bool | None = None) None
Parameters:
start() None

Start the thread’s activity and wait until the server is ready for accepting requests.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

join(timeout: float | None = None) None

Wait until the thread terminates.

This calls the server’s shutdown() method and then the default join() method.

Parameters:

timeout (float | None) – when it present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join to decide whether a timeout happened – if the thread is still alive, the join() call timed out. The time taken by shutdown() is substracted.