@sync_to_async(thread_sensitive=True)
See original GitHub issueHi - thank you for this wonderful project and its integration in Django 3.
I think I have noticed a bug - although it could be in my head. I believe the decorator @sync_to_async(thread_sensitive=True)
as shown here is causing an error as follows:
@sync_to_async(thread_sensitive=True) TypeError: __init__() missing 1 required positional argument: 'func'
Using it as a function call await sync_to_async(my_sync_function, thread_sensitive=True)()
works fine. I will look through the code and see if I can figure out how to fix this. I noticed there were no tests specifically testing the decorator with this option set.
Cheers KB
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Source code for asgiref.sync - Django documentation
Look for the threadlocal if # we're inside SyncToAsync main_event_loop_pid = getattr( SyncToAsync.threadlocal, "main_event_loop_pid", None ) # We make sure ...
Read more >How to use the asgiref.sync.sync_to_async function in ... - Snyk
async def test_thread_sensitive_outside_async(): """ Tests that thread_sensitive SyncToAsync where the outside is async code runs in a single, ...
Read more >Asynchronous support — Django 4.1.4 documentation
Django has support for writing asynchronous (“async”) views, along with an entirely async-enabled request stack if you are running under ASGI. Async views...
Read more >Django: SynchronousOnlyOperation: You cannot call this from ...
from asgiref.sync import sync_to_async users = sync_to_async(User.objects.all()) for user in users: print(user) TypeError: 'SyncToAsync' ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Still having the issues as of now
It wouldn’t be good form to mix it up with a pull request for a different thing - happy to accept a separate PR for that, though.