:right-sidebar: True ThreadedSocketService =================================================================== .. currentmodule:: gi.repository.Gio .. versionadded:: 2.22 .. class:: ThreadedSocketService(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gio.SocketService`, :class:`~gi.repository.Gio.SocketListener`, :class:`~gi.repository.GObject.Object` A ``GThreadedSocketService`` is a simple subclass of :obj:`~gi.repository.Gio.SocketService` that handles incoming connections by creating a worker thread and dispatching the connection to it by emitting the :obj:`~gi.repository.Gio.ThreadedSocketService.signals.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 :obj:`~gi.repository.Gio.SocketService` from accepting new connections when all threads are busy. As with :obj:`~gi.repository.Gio.SocketService`\, you may connect to :obj:`~gi.repository.Gio.ThreadedSocketService.signals.run`\, or subclass and override the default handler. Constructors ------------ .. rst-class:: interim-class .. class:: ThreadedSocketService :no-index: .. classmethod:: new(max_threads: int) -> ~gi.repository.Gio.SocketService Creates a new :obj:`~gi.repository.Gio.ThreadedSocketService` with no listeners. Listeners must be added with one of the :obj:`~gi.repository.Gio.SocketListener` "add" methods. .. versionadded:: 2.22 :param max_threads: the maximal number of threads to execute concurrently handling incoming clients, -1 means no limit Methods ------- .. rst-class:: interim-class .. class:: ThreadedSocketService :no-index: .. method:: do_run(self, connection: ~gi.repository.Gio.SocketConnection, source_object: ~gi.repository.GObject.Object) -> bool :param connection: :param source_object: Properties ---------- .. rst-class:: interim-class .. class:: ThreadedSocketService :no-index: .. attribute:: props.max_threads :type: int The type of the None singleton. .. versionadded:: 2.22 Signals ------- .. rst-class:: interim-class .. class:: ThreadedSocketService.signals :no-index: .. method:: run(connection: ~gi.repository.Gio.SocketConnection, source_object: ~gi.repository.GObject.Object | None = None) -> bool The type of the None singleton. :param connection: a new :obj:`~gi.repository.Gio.SocketConnection` object. :param source_object: the source_object passed to :func:`~gi.repository.Gio.SocketListener.add_address`. Virtual Methods --------------- .. rst-class:: interim-class .. class:: ThreadedSocketService :no-index: .. method:: do_run(connection: ~gi.repository.Gio.SocketConnection, source_object: ~gi.repository.GObject.Object) -> bool The type of the None singleton. :param connection: :param source_object: Fields ------ .. rst-class:: interim-class .. class:: ThreadedSocketService :no-index: .. attribute:: parent_instance .. attribute:: priv