question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@sync_to_async(thread_sensitive=True)

See original GitHub issue

Hi - 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:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
updatedennismwangicommented, Aug 30, 2020

Still having the issues as of now

0reactions
andrewgodwincommented, May 14, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found