File tree 4 files changed +15
-13
lines changed
4 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,10 @@ Unreleased
26
26
27
27
**Added **
28
28
29
- - :pull: `1165 ` - Allow concurrent renders of discrete component tree - enable this
30
- experimental feature by setting `REACTPY_ASYNC_RENDERING=true `. This should improve
31
- the overall responsiveness of your app, particularly when handling larger renders
32
- that would otherwise block faster renders from being processed .
29
+ - :pull: `1165 ` - Allow concurrently rendering discrete component trees - enable this
30
+ experimental feature by setting `REACTPY_ASYNC_RENDERING=true `. This improves
31
+ the overall responsiveness of your app in situations where larger renders would
32
+ otherwise block smaller renders from executing .
33
33
34
34
**Changed **
35
35
Original file line number Diff line number Diff line change @@ -82,9 +82,9 @@ def boolean(value: str | bool | int) -> bool:
82
82
"""A default timeout for testing utilities in ReactPy"""
83
83
84
84
REACTPY_ASYNC_RENDERING = Option (
85
- "REACTPY_CONCURRENT_RENDERING " ,
85
+ "REACTPY_ASYNC_RENDERING " ,
86
86
default = False ,
87
87
mutable = True ,
88
88
validator = boolean ,
89
89
)
90
- """Whether to render components concurrently . This is currently an experimental feature."""
90
+ """Whether to render components asynchronously . This is currently an experimental feature."""
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ async def deliver(self, event: LayoutEventMessage) -> None:
129
129
130
130
async def render (self ) -> LayoutUpdateMessage :
131
131
if REACTPY_ASYNC_RENDERING .current :
132
- return await self ._concurrent_render ()
132
+ return await self ._parallel_render ()
133
133
else : # nocov
134
134
return await self ._serial_render ()
135
135
@@ -147,8 +147,10 @@ async def _serial_render(self) -> LayoutUpdateMessage: # nocov
147
147
else :
148
148
return await self ._create_layout_update (model_state )
149
149
150
- async def _concurrent_render (self ) -> LayoutUpdateMessage :
151
- """Await the next available render. This will block until a component is updated"""
150
+ async def _parallel_render (self ) -> LayoutUpdateMessage :
151
+ """Await to fetch the first completed render within our asyncio task group.
152
+ We use the `asyncio.tasks.wait` API in order to return the first completed task.
153
+ """
152
154
await self ._render_tasks_ready .acquire ()
153
155
done , _ = await wait (self ._render_tasks , return_when = FIRST_COMPLETED )
154
156
update_task : Task [LayoutUpdateMessage ] = done .pop ()
Original file line number Diff line number Diff line change 32
32
33
33
34
34
@pytest .fixture (autouse = True , params = [True , False ])
35
- def concurrent_rendering (request ):
35
+ def async_rendering (request ):
36
36
with patch .object (REACTPY_ASYNC_RENDERING , "current" , request .param ):
37
37
yield request .param
38
38
@@ -1252,9 +1252,9 @@ def App():
1252
1252
assert c ["attributes" ]["color" ] == "blue"
1253
1253
1254
1254
1255
- async def test_concurrent_renders ( concurrent_rendering ):
1256
- if not concurrent_rendering :
1257
- raise pytest .skip ("Concurrent rendering not enabled" )
1255
+ async def test_async_renders ( async_rendering ):
1256
+ if not async_rendering :
1257
+ raise pytest .skip ("Async rendering not enabled" )
1258
1258
1259
1259
child_1_hook = HookCatcher ()
1260
1260
child_2_hook = HookCatcher ()
You can’t perform that action at this time.
0 commit comments