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, typically a background task or callback that requires access to Flask's request or session objects.

Returns

TypeDescription
FA wrapped version of the input function that automatically pushes the captured request context before execution.