Skip to content

Commit

Permalink
Another attempt to fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Dec 28, 2024
1 parent 8ba4777 commit 3afad19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Don't forget to remove deprecated code on each major release!

### Fixed

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

## [5.1.1] - 2024-12-02

Expand Down
9 changes: 4 additions & 5 deletions src/reactpy_django/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
+ r"\s*%}"
)
FILE_ASYNC_ITERATOR_THREAD = ThreadPoolExecutor(max_workers=1, thread_name_prefix="ReactPy-Django-FileAsyncIterator")
SYNC_LAYOUT_THREAD = ThreadPoolExecutor(max_workers=1, thread_name_prefix="ReactPy-Django-SyncLayout")


async def render_view(
Expand Down Expand Up @@ -354,17 +355,15 @@ class SyncLayout(Layout):

def __enter__(self):
self.loop = asyncio.new_event_loop()
self.thread = ThreadPoolExecutor(max_workers=1)
self.thread.submit(self.loop.run_until_complete, self.__aenter__()).result()
SYNC_LAYOUT_THREAD.submit(self.loop.run_until_complete, self.__aenter__()).result()
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.thread.submit(self.loop.run_until_complete, self.__aexit__()).result()
SYNC_LAYOUT_THREAD.submit(self.loop.run_until_complete, self.__aexit__()).result()
self.loop.close()
self.thread.shutdown()

def sync_render(self):
return self.thread.submit(self.loop.run_until_complete, self.render()).result()
return SYNC_LAYOUT_THREAD.submit(self.loop.run_until_complete, self.render()).result()


def get_pk(model):
Expand Down

0 comments on commit 3afad19

Please sign in to comment.