Gio.ThreadedSocketService¶
- Subclasses:
None
Methods¶
- Inherited:
Gio.SocketService (4), Gio.SocketListener (13), GObject.Object (37)
- Structs:
class |
|
Virtual Methods¶
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
Signals¶
Name |
Short Description |
---|---|
The |
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gio.ThreadedSocketService(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A
GThreadedSocketService
is a simple subclass of [class`Gio`.SocketService] that handles incoming connections by creating a worker thread and dispatching the connection to it by emitting the [signal`Gio`.ThreadedSocketService::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 [class`Gio`.SocketService] from accepting new connections when all threads are busy.
As with [class`Gio`.SocketService], you may connect to [signal`Gio`.ThreadedSocketService::run], or subclass and override the default handler.
New in version 2.22.
- classmethod new(max_threads)[source]¶
- Parameters:
max_threads (
int
) – the maximal number of threads to execute concurrently handling incoming clients, -1 means no limit- Returns:
a new
Gio.SocketService
.- Return type:
Creates a new
Gio.ThreadedSocketService
with no listeners. Listeners must be added with one of theGio.SocketListener
“add” methods.New in version 2.22.
- do_run(connection, source_object) virtual¶
- Parameters:
connection (
Gio.SocketConnection
) –source_object (
GObject.Object
) –
- Return type:
Signal Details¶
- Gio.ThreadedSocketService.signals.run(threaded_socket_service, connection, source_object)¶
- Signal Name:
run
- Flags:
- Parameters:
threaded_socket_service (
Gio.ThreadedSocketService
) – The object which received the signalconnection (
Gio.SocketConnection
) – a newGio.SocketConnection
object.source_object (
GObject.Object
orNone
) – the source_object passed toGio.SocketListener.add_address
().
- Returns:
True
to stop further signal handlers from being called- Return type:
The
::run
signal is emitted in a worker thread in response to an incoming connection. This thread is dedicated to handling connection and may perform blocking IO. The signal handler need not return until the connection is closed.
Property Details¶
- Gio.ThreadedSocketService.props.max_threads¶
- Name:
max-threads
- Type:
- Default Value:
10
- Flags:
The maximum number of threads handling clients for this service.
New in version 2.22.