Skip to main content

BackgroundTasks

A collection of background tasks that will be called after a response has been sent to the client.

Methods​


add_task()​

@classmethod
def add_task(
func: Callable[P, Any],
args: P.args,
kwargs: P.kwargs
) - > None

Add a function to be called in the background after the response is sent.

Parameters​

NameTypeDescription
funcCallable[P, Any]The function to call after the response is sent. It can be a regular def function or an async def function.
argsP.argsPositional arguments to pass to the background function.
kwargsP.kwargsKeyword arguments to pass to the background function.

Returns​

TypeDescription
None