ThreadedSocketService#

Added in version 2.22.

class ThreadedSocketService(**properties: Any)#

Superclasses: SocketService, SocketListener, Object

A GThreadedSocketService is a simple subclass of SocketService that handles incoming connections by creating a worker thread and dispatching the connection to it by emitting the run signal in the new thread.

The signal handler may perform blocking I/O and need not return until the connection is closed.

The service is implemented using a thread pool, so there is a limited amount of threads available to serve incoming requests. The service automatically stops the SocketService from accepting new connections when all threads are busy.

As with SocketService, you may connect to run, or subclass and override the default handler.

Constructors#

class ThreadedSocketService
classmethod new(max_threads: int) SocketService#

Creates a new ThreadedSocketService with no listeners. Listeners must be added with one of the SocketListener “add” methods.

Added in version 2.22.

Parameters:

max_threads – the maximal number of threads to execute concurrently handling incoming clients, -1 means no limit

Methods#

class ThreadedSocketService
do_run(self, connection: SocketConnection, source_object: Object) bool#
Parameters:
  • connection

  • source_object

Properties#

class ThreadedSocketService
props.max_threads: int#

The type of the None singleton.

Added in version 2.22.

Signals#

class ThreadedSocketService.signals
run(connection: SocketConnection, source_object: Object | None = None) bool#

The type of the None singleton.

Parameters:

Virtual Methods#

class ThreadedSocketService
do_run(connection: SocketConnection, source_object: Object) bool#

The type of the None singleton.

Parameters:
  • connection

  • source_object

Fields#

class ThreadedSocketService
parent_instance#
priv#