Skip to content

Commit a43dea2

Browse files
committed
Export reactive.lock
1 parent b247baa commit a43dea2

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

shiny/reactive/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
isolate,
33
invalidate_later,
44
flush,
5+
lock,
56
on_flushed,
67
get_current_context, # pyright: ignore[reportUnusedImport]
78
)
@@ -18,14 +19,15 @@
1819

1920

2021
__all__ = (
22+
"isolate",
23+
"invalidate_later",
2124
"flush",
25+
"lock",
2226
"on_flushed",
27+
"poll",
28+
"file_reader",
2329
"Value",
2430
"Calc",
2531
"Effect",
2632
"event",
27-
"isolate",
28-
"invalidate_later",
29-
"poll",
30-
"file_reader",
3133
)

shiny/reactive/_core.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
from __future__ import annotations
44

5-
__all__ = ("isolate", "invalidate_later", "flush", "on_flushed", "get_current_context")
5+
__all__ = (
6+
"isolate",
7+
"invalidate_later",
8+
"flush",
9+
"lock",
10+
"on_flushed",
11+
"get_current_context",
12+
)
613

714
import asyncio
815
import contextlib
@@ -279,7 +286,13 @@ def on_flushed(
279286

280287

281288
def lock() -> asyncio.Lock:
282-
"""A lock that should be held whenever manipulating the reactive graph."""
289+
"""
290+
A lock that should be held whenever manipulating the reactive graph.
291+
292+
For example, this makes it safe to set a :class:`~reactive.Value` and call
293+
:func:`~reactive.flush()` from a different :class:`~asyncio.Task` than the one that
294+
is running the Shiny :class:`~shiny.Session`.
295+
"""
283296
return _reactive_environment.lock
284297

285298

0 commit comments

Comments
 (0)