Skip to content

Commit

Permalink
Concurrent rendering naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Mar 8, 2024
1 parent 4307a09 commit a8286ce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Unreleased

**Added**

- :pull:`1165` - Allow concurrent renders of discrete component tree - enable this
- :pull:`1165` - Allow asynchronously rendering discrete component tree - enable this
experimental feature by setting `REACTPY_ASYNC_RENDERING=true`. This should improve
the overall responsiveness of your app, particularly when handling larger renders
that would otherwise block faster renders from being processed.
Expand Down
4 changes: 2 additions & 2 deletions src/py/reactpy/reactpy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def boolean(value: str | bool | int) -> bool:
"""A default timeout for testing utilities in ReactPy"""

REACTPY_ASYNC_RENDERING = Option(
"REACTPY_CONCURRENT_RENDERING",
"REACTPY_ASYNC_RENDERING",
default=False,
mutable=True,
validator=boolean,
)
"""Whether to render components concurrently. This is currently an experimental feature."""
"""Whether to render components asynchronously. This is currently an experimental feature."""
6 changes: 3 additions & 3 deletions src/py/reactpy/reactpy/core/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def deliver(self, event: LayoutEventMessage) -> None:

async def render(self) -> LayoutUpdateMessage:
if REACTPY_ASYNC_RENDERING.current:
return await self._concurrent_render()
return await self._parallel_render()
else: # nocov
return await self._serial_render()

Expand All @@ -147,8 +147,8 @@ async def _serial_render(self) -> LayoutUpdateMessage: # nocov
else:
return await self._create_layout_update(model_state)

async def _concurrent_render(self) -> LayoutUpdateMessage:
"""Await the next available render. This will block until a component is updated"""
async def _parallel_render(self) -> LayoutUpdateMessage:
"""Await the next available render within an asyncio task group."""
await self._render_tasks_ready.acquire()
done, _ = await wait(self._render_tasks, return_when=FIRST_COMPLETED)
update_task: Task[LayoutUpdateMessage] = done.pop()
Expand Down
8 changes: 4 additions & 4 deletions src/py/reactpy/tests/test_core/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


@pytest.fixture(autouse=True, params=[True, False])
def concurrent_rendering(request):
def async_rendering(request):
with patch.object(REACTPY_ASYNC_RENDERING, "current", request.param):
yield request.param

Expand Down Expand Up @@ -1252,9 +1252,9 @@ def App():
assert c["attributes"]["color"] == "blue"


async def test_concurrent_renders(concurrent_rendering):
if not concurrent_rendering:
raise pytest.skip("Concurrent rendering not enabled")
async def test_async_renders(async_rendering):
if not async_rendering:
raise pytest.skip("Async rendering not enabled")

child_1_hook = HookCatcher()
child_2_hook = HookCatcher()
Expand Down

0 comments on commit a8286ce

Please sign in to comment.