File tree 2 files changed +14
-6
lines changed
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ Don't forget to remove deprecated code on each major release!
32
32
33
33
- Refactoring of internal code to improve maintainability. No changes to publicly documented API.
34
34
35
+ ### Fixed
36
+
37
+ - Fixed bug where prerendered components could generate a ` SynchronousOnlyOperation ` exception if they utilize the Django ORM.
38
+
35
39
## [ 5.1.1] - 2024-12-02
36
40
37
41
### Fixed
Original file line number Diff line number Diff line change 2
2
3
3
from __future__ import annotations
4
4
5
+ import asyncio
5
6
import contextlib
6
7
import inspect
7
8
import logging
16
17
from uuid import UUID , uuid4
17
18
18
19
import dill
19
- from asgiref .sync import async_to_sync
20
20
from channels .db import database_sync_to_async
21
21
from django .contrib .staticfiles .finders import find
22
22
from django .core .cache import caches
@@ -353,14 +353,18 @@ class SyncLayout(Layout):
353
353
"""
354
354
355
355
def __enter__ (self ):
356
- async_to_sync (self .__aenter__ )()
357
- return self
356
+ self .loop = asyncio .new_event_loop ()
357
+ self .thread = ThreadPoolExecutor (max_workers = 1 )
358
+ return self .thread .submit (self .loop .run_until_complete , self .__aenter__ ()).result ()
358
359
359
- def __exit__ (self , * _ ):
360
- async_to_sync (self .__aexit__ )(* _ )
360
+ def __exit__ (self , * exec ):
361
+ result = self .thread .submit (self .loop .run_until_complete , self .__aexit__ (* exec )).result ()
362
+ self .loop .close ()
363
+ self .thread .shutdown ()
364
+ return result
361
365
362
366
def sync_render (self ):
363
- return async_to_sync ( super (). render ) ()
367
+ return self . thread . submit ( self . loop . run_until_complete , self . render ()). result ()
364
368
365
369
366
370
def get_pk (model ):
You can’t perform that action at this time.
0 commit comments