Skip to content

Commit 7ef4dbd

Browse files
committed
add nest_asyncio
1 parent 6deefd4 commit 7ef4dbd

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Using the following categories, list your changes in this order:
4141
### Added
4242

4343
- ReactPy Websocket will now decode messages via `orjson` resulting in an ~6% overall performance boost.
44+
- Built-in asyncio event loops are now patched via `nest_asyncio` to be re-enterant, resulting in an ~10% overall performance boost. This has no performance impact if you are running your webserver with `uvloop`.
4445

4546
### Changed
4647

@@ -49,6 +50,8 @@ Using the following categories, list your changes in this order:
4950
### Fixed
5051

5152
- Fix bug where `REACTPY_WEBSOCKET_URL` always generates a warning if unset.
53+
- Fixed bug where `assert f is self._write_fut` would be raised within Uvicorn on Windows when `REACTPY_BACKHAUL_THREAD = True`.
54+
- Fixed bug where rendering behavior would be jittery with Daphne on Windows when `REACTPY_BACKHAUL_THREAD = True`.
5255

5356
## [3.3.1] - 2023-08-08
5457

requirements/pkg-deps.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ django >=4.1.0
33
reactpy >=1.0.0, <1.1.0
44
aiofile >=3.0
55
dill >=0.3.5
6-
orjson >=3.0.0
6+
orjson >=3.6.0
7+
nest_asyncio >=1.5.0
78
typing_extensions

src/reactpy_django/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import contextlib
2+
3+
import nest_asyncio
4+
15
from reactpy_django import checks, components, decorators, hooks, types, utils
26
from reactpy_django.websocket.paths import REACTPY_WEBSOCKET_PATH
37

@@ -11,3 +15,9 @@
1115
"utils",
1216
"checks",
1317
]
18+
# Built-in asyncio event loops can create `assert f is self._write_fut` exceptions
19+
# while we are using our backhaul thread, so we use this patch to fix this.
20+
# This also resolves jittery rendering behaviors within Daphne. Can be demonstrated
21+
# using our "Renders Per Second" test page.
22+
with contextlib.suppress(ValueError):
23+
nest_asyncio.apply()

0 commit comments

Comments
 (0)