Skip to content

Commit 188198a

Browse files
committed
REACTPY_ASYNC_RENDERING
1 parent ccf6f11 commit 188198a

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ Don't forget to remove deprecated code on each major release!
3636

3737
## [Unreleased]
3838

39-
- Nothing (yet)!
39+
### Added
40+
41+
- `settings.py:REACTPY_ASYNC_RENDERING` to enable asynchronous rendering of components.
4042

4143
## [5.0.0] - 2024-10-22
4244

docs/src/reference/settings.md

+12
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,18 @@ This setting is incompatible with [`daphne`](https://github.com/django/daphne).
123123

124124
---
125125

126+
### `#!python REACTPY_ASYNC_RENDERING`
127+
128+
**Default:** `#!python False`
129+
130+
**Example Value(s):** `#!python True`
131+
132+
Configures whether to use an async ReactPy rendering queue. When enabled, large renders will no longer block smaller renders from taking place. Additionally, prevents the rendering queue from being blocked on waiting for async effects to startup/shutdown (which is typically a relatively slow operation).
133+
134+
This setting is currently experimental, and currently no effort is made to de-duplicate renders. For example, if parent and child components are scheduled to render at the same time, both renders will take place even though a single render of the parent component would have been sufficient.
135+
136+
---
137+
126138
### `#!python REACTPY_DEFAULT_HOSTS`
127139

128140
**Default:** `#!python None`

src/reactpy_django/config.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.core.cache import DEFAULT_CACHE_ALIAS
88
from django.db import DEFAULT_DB_ALIAS
99
from django.views import View
10+
from reactpy.config import REACTPY_ASYNC_RENDERING as _REACTPY_ASYNC_RENDERING
1011
from reactpy.config import REACTPY_DEBUG_MODE as _REACTPY_DEBUG_MODE
1112
from reactpy.core.types import ComponentConstructor
1213

@@ -17,13 +18,16 @@
1718
from reactpy_django.utils import import_dotted_path
1819

1920
# Non-configurable values
20-
_REACTPY_DEBUG_MODE.set_current(getattr(settings, "DEBUG"))
2121
REACTPY_DEBUG_MODE = _REACTPY_DEBUG_MODE.current
2222
REACTPY_REGISTERED_COMPONENTS: dict[str, ComponentConstructor] = {}
2323
REACTPY_FAILED_COMPONENTS: set[str] = set()
2424
REACTPY_REGISTERED_IFRAME_VIEWS: dict[str, Callable | View] = {}
2525

2626
# Configurable through Django settings.py
27+
_REACTPY_DEBUG_MODE.set_current(getattr(settings, "DEBUG"))
28+
_REACTPY_ASYNC_RENDERING.set_current(
29+
getattr(settings, "REACTPY_ASYNC_RENDERING", _REACTPY_ASYNC_RENDERING.current)
30+
)
2731
REACTPY_URL_PREFIX: str = getattr(
2832
settings,
2933
"REACTPY_URL_PREFIX",

src/reactpy_django/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def generate_obj_name(obj: Any) -> str:
263263
"""Makes a best effort to create a name for an object.
264264
Useful for JSON serialization of Python objects."""
265265

266-
# First attempt: Dunder methods
266+
# First attempt: Create a dotted path by inspecting dunder methods
267267
if hasattr(obj, "__module__"):
268268
if hasattr(obj, "__name__"):
269269
return f"{obj.__module__}.{obj.__name__}"

0 commit comments

Comments
 (0)