Skip to main content

copy_current_request_context

Decorate a function to run inside the current request context. This can be used when starting a background task, otherwise it will not see the app and request objects that were active in the parent.

def copy_current_request_context(
f: F
) - > F

Decorate a function to run inside the current request context. This can be used when starting a background task, otherwise it will not see the app and request objects that were active in the parent.

Parameters

NameTypeDescription
fFThe function to be decorated and run within the copied request context.

Returns

TypeDescription
FThe decorated function that will execute within a copy of the request context.