Skip to content

Work

A decorator used to create workers.

Parameters
Parameter Default Description
method
Callable[FactoryParamSpec, ReturnType] | Callable[FactoryParamSpec, Coroutine[None, None, ReturnType]] | None
None

A function or coroutine.

name
str
''

A short string to identify the worker (in logs and debugging).

group
str
'default'

A short string to identify a group of workers.

exit_on_error
bool
True

Exit the app if the worker raises an error. Set to False to suppress exceptions.

exclusive
bool
False

Cancel all workers in the same group.

description
str | None
None

Readable description of the worker for debugging purposes. By default, it uses a string representation of the decorated method and its arguments.

thread
bool
False

Mark the method as a thread worker.