Gio.ThreadedSocketService

g GObject.Object GObject.Object Gio.SocketListener Gio.SocketListener GObject.Object->Gio.SocketListener Gio.SocketService Gio.SocketService Gio.SocketListener->Gio.SocketService Gio.ThreadedSocketService Gio.ThreadedSocketService Gio.SocketService->Gio.ThreadedSocketService

Subclasses:

None

Methods

Inherited:

Gio.SocketService (4), Gio.SocketListener (13), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (max_threads)

Virtual Methods

Inherited:

Gio.SocketService (1), Gio.SocketListener (2), GObject.Object (7)

do_run (connection, source_object)

Properties

Inherited:

Gio.SocketService (1), Gio.SocketListener (1)

Name

Type

Flags

Short Description

max-threads

int

r/w/co

Signals

Inherited:

Gio.SocketService (1), Gio.SocketListener (1), GObject.Object (1)

Name

Short Description

run

The ::run signal is emitted in a worker thread in response to an incoming connection.

Fields

Inherited:

Gio.SocketService (1), Gio.SocketListener (1), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gio.SocketService

r

Class Details

class Gio.ThreadedSocketService(**kwargs)
Bases:

Gio.SocketService

Abstract:

No

Structure:

Gio.ThreadedSocketServiceClass

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:

Gio.SocketService

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

New in version 2.22.

do_run(connection, source_object) virtual
Parameters:
Return type:

bool

Signal Details

Gio.ThreadedSocketService.signals.run(threaded_socket_service, connection, source_object)
Signal Name:

run

Flags:

RUN_LAST

Parameters:
Returns:

True to stop further signal handlers from being called

Return type:

bool

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:

int

Default Value:

10

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The maximum number of threads handling clients for this service.

New in version 2.22.