plesty.server.view.workers ========================== .. py:module:: plesty.server.view.workers .. autoapi-nested-parse:: Run presenter calls off the GUI thread and hand the result back as a signal. A :class:`Bench` call may block for seconds — ``start`` waits for the probe, ``stop`` for the escalation — and Qt paints nothing while its thread is busy. :class:`Worker` puts the call on a thread pool and emits ``done(result)`` or ``failed(message)`` on the GUI thread, where the window connects its slots. Classes ------- .. autoapisummary:: plesty.server.view.workers._Signals plesty.server.view.workers._Task plesty.server.view.workers.Worker Module Contents --------------- .. py:class:: _Signals Bases: :py:obj:`PySide6.QtCore.QObject` .. py:attribute:: done .. py:attribute:: failed .. py:class:: _Task(action: collections.abc.Callable[[], Any], signals: _Signals) Bases: :py:obj:`PySide6.QtCore.QRunnable` .. py:attribute:: _action .. py:attribute:: _signals .. py:method:: run() -> None .. py:class:: Worker(parent: PySide6.QtCore.QObject | None = None, threads: int = 4) Bases: :py:obj:`PySide6.QtCore.QObject` A small pool running one presenter call per task. Usage:: worker.run(lambda: bench.start(name), on_done=self._show_status, on_error=self._alert) Create the pool. :param parent: Qt parent. :param threads: Concurrent tasks — more than one so a long ``stop`` does not block a status refresh. .. py:attribute:: _pool .. py:attribute:: _live :type: list[_Signals] :value: [] .. py:method:: run(action: collections.abc.Callable[[], Any], on_done: collections.abc.Callable[[Any], None] | None = None, on_error: collections.abc.Callable[[str], None] | None = None) -> None Run *action* on the pool; call *on_done* or *on_error* on the GUI thread. .. py:method:: wait(timeout_ms: int = 30000) -> bool Block until every task finished (tests); ``True`` when none is left. .. py:property:: busy :type: bool Whether any task is still running.