Skip to content

Commit 3afad19

Browse files
committed
Another attempt to fix tests.
1 parent 8ba4777 commit 3afad19

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

CHANGELOG.md

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

3535
### Fixed
3636

37-
- Fixed bug where prerendered components could generate a `SynchronousOnlyOperation` exception if they utilize the Django ORM.
37+
- Fixed bug where pre-rendered components could generate a `SynchronousOnlyOperation` exception if they utilize the Django ORM.
3838

3939
## [5.1.1] - 2024-12-02
4040

src/reactpy_django/utils.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
+ r"\s*%}"
6363
)
6464
FILE_ASYNC_ITERATOR_THREAD = ThreadPoolExecutor(max_workers=1, thread_name_prefix="ReactPy-Django-FileAsyncIterator")
65+
SYNC_LAYOUT_THREAD = ThreadPoolExecutor(max_workers=1, thread_name_prefix="ReactPy-Django-SyncLayout")
6566

6667

6768
async def render_view(
@@ -354,17 +355,15 @@ class SyncLayout(Layout):
354355

355356
def __enter__(self):
356357
self.loop = asyncio.new_event_loop()
357-
self.thread = ThreadPoolExecutor(max_workers=1)
358-
self.thread.submit(self.loop.run_until_complete, self.__aenter__()).result()
358+
SYNC_LAYOUT_THREAD.submit(self.loop.run_until_complete, self.__aenter__()).result()
359359
return self
360360

361361
def __exit__(self, exc_type, exc_val, exc_tb):
362-
self.thread.submit(self.loop.run_until_complete, self.__aexit__()).result()
362+
SYNC_LAYOUT_THREAD.submit(self.loop.run_until_complete, self.__aexit__()).result()
363363
self.loop.close()
364-
self.thread.shutdown()
365364

366365
def sync_render(self):
367-
return self.thread.submit(self.loop.run_until_complete, self.render()).result()
366+
return SYNC_LAYOUT_THREAD.submit(self.loop.run_until_complete, self.render()).result()
368367

369368

370369
def get_pk(model):

0 commit comments

Comments
 (0)