aqt.taskman
===========

.. py:module:: aqt.taskman

.. autoapi-nested-parse::

   Helper for running tasks on background threads.

   See QueryOp() and CollectionOp() for higher-level routines.



Attributes
----------

.. autoapisummary::

   aqt.taskman.Closure


Classes
-------

.. autoapisummary::

   aqt.taskman.TaskManager


Module Contents
---------------

.. py:data:: Closure

.. py:class:: TaskManager(mw: aqt.AnkiQt)

   Bases: :py:obj:`QObject`


   .. py:attribute:: mw


   .. py:method:: run_on_main(closure: Closure) -> None

      Run the provided closure on the main thread.



   .. py:method:: run_in_background(task: collections.abc.Callable, on_done: collections.abc.Callable[[concurrent.futures.Future], None] | None = None, args: dict[str, Any] | None = None, uses_collection=True) -> concurrent.futures.Future

      Use QueryOp()/CollectionOp() in new code.

      Run task on a background thread.

      If on_done is provided, it will be called on the main thread with
      the completed future.

      Args if provided will be passed on as keyword arguments to the task callable.

      Tasks that access the collection are serialized. If you're doing things that
      don't require the collection (e.g. network requests), you can pass uses_collection
      =False to allow multiple tasks to run in parallel.



   .. py:method:: with_progress(task: collections.abc.Callable, on_done: collections.abc.Callable[[concurrent.futures.Future], None] | None = None, parent: QWidget | None = None, label: str | None = None, immediate: bool = False, uses_collection=True, title: str = 'Anki') -> None

      Use QueryOp()/CollectionOp() in new code.



   .. py:method:: with_backend_progress(task: collections.abc.Callable, progress_update: collections.abc.Callable[[anki.collection.Progress, aqt.progress.ProgressUpdate], None], on_done: collections.abc.Callable[[concurrent.futures.Future], None] | None = None, parent: QWidget | None = None, start_label: str | None = None, uses_collection=True) -> None


