background_tasks

class litestar.background_tasks.BackgroundTask[原始碼]

基底類別:object

A container for a 'background' task function.

Background tasks are called once a Response finishes.

__init__(fn: ~typing.Callable[[~P], ~typing.Any], *args: ~typing.~P, **kwargs: ~typing.~P) None[原始碼]

初始化 BackgroundTask

參數:
  • fn -- A sync or async function to call as the background task.

  • *args -- Args to pass to the func.

  • **kwargs -- Kwargs to pass to the func

async __call__() None[原始碼]

Call the wrapped function with the passed in arguments.

回傳:

None

class litestar.background_tasks.BackgroundTasks[原始碼]

基底類別:object

A container for multiple 'background' task functions.

Background tasks are called once a Response finishes.

__init__(tasks: Iterable[BackgroundTask], run_in_task_group: bool = False) None[原始碼]

初始化 BackgroundTasks

參數:
  • tasks -- An iterable of BackgroundTask instances.

  • run_in_task_group -- If you set this value to True than the tasks will run concurrently, using a TaskGroup. Note: This will not preserve execution order.

async __call__() None[原始碼]

Call the wrapped background tasks.

回傳:

None