Skip to content

Commit 492ef06

Browse files
committed
Clarify use of context-locals with signals.
1 parent b16c988 commit 492ef06

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/signals.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ debugging. You can access the name of the signal with the
131131
missing blinker installations, you can do so by using the
132132
:class:`flask.signals.Namespace` class.
133133

134+
.. _signals-sending:
135+
134136
Sending Signals
135137
---------------
136138

@@ -156,6 +158,17 @@ function, you can pass ``current_app._get_current_object()`` as sender.
156158
that :data:`~flask.current_app` is a proxy and not the real application
157159
object.
158160

161+
162+
Signals and Flask's Request Context
163+
-----------------------------------
164+
165+
Signals fully support :ref:`reqcontext` when receiving signals. Context-local
166+
variables are consistently available between :data:`~flask.request_started` and
167+
:data:`~flask.request_finished`, so you can rely on :class:`flask.g` and others
168+
as needed. Note the limitations described in :ref:`signals-sending` and the
169+
:data:`~flask.request_tearing_down` signal.
170+
171+
159172
Decorator Based Signal Subscriptions
160173
------------------------------------
161174

0 commit comments

Comments
 (0)