[go: up one dir, main page]

Skip to content

textual.worker_manager

Contains WorkerManager, a class to manage workers for an app.

You access this object via App.workers or Widget.workers.

WorkerManager

WorkerManager(app)

An object to manager a number of workers.

You will not have to construct this class manually, as widgets, screens, and apps have a worker manager accessibly via a workers attribute.

Parameters:

Name Type Description Default

app

App

An App instance.

required

add_worker

add_worker(worker, start=True, exclusive=True)

Add a new worker.

Parameters:

Name Type Description Default

worker

Worker

A Worker instance.

required

start

bool

Start the worker if True, otherwise the worker must be started manually.

True

exclusive

bool

Cancel all workers in the same group as worker.

True

cancel_all

cancel_all()

Cancel all workers.

cancel_group

cancel_group(node, group)

Cancel a single group.

Parameters:

Name Type Description Default

node

DOMNode

Worker DOM node.

required

group

str

A group name.

required

Returns:

Type Description
list[Worker]

A list of workers that were cancelled.

cancel_node

cancel_node(node)

Cancel all workers associated with a given node

Parameters:

Name Type Description Default

node

DOMNode

A DOM node (widget, screen, or App).

required

Returns:

Type Description
list[Worker]

List of cancelled workers.

start_all

start_all()

Start all the workers.

wait_for_complete async

wait_for_complete(workers=None)

Wait for workers to complete.

Parameters:

Name Type Description Default

workers

Iterable[Worker] | None

An iterable of workers or None to wait for all workers in the manager.

None