Server implementation tools — Threads helper
Server implementation tools module for thread management.
Background Server Thread
- class easynetwork.servers.threads_helper.NetworkServerThread
Bases:
ThreadA
Threaddedicated to network servers.- __init__(server: AbstractNetworkServer, group: None = None, name: str | None = None, *, daemon: bool | None = None) None
- Parameters:
server (AbstractNetworkServer) – the network server implementation to manage.
group (None) – See
threading.Threadfor details.name (str | None) – See
threading.Threadfor details.daemon (bool | None) – See
threading.Threadfor details.
- 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
RuntimeErrorif 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 defaultjoin()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 callis_alive()after join to decide whether a timeout happened – if the thread is still alive, the join() call timed out. The time taken byshutdown()is substracted.