asgiref
asgiref copied to clipboard
@sync_to_async(thread_sensitive=True)
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
Hi @kbhalerao
I think you've found the problem. It's documented as supporting that, but the code doesn't. It needs a test, then refactoring to match that.
Yeah, I'm going to remove that from the documentation for now as it doesn't work yet. We should, however, add support for it in.
I opened a PR to remove the doc example here: https://github.com/django/django/pull/12706
Happy to include support for doing this, as a part of https://github.com/django/asgiref/pull/159, or once its merged in.
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.
Still having the issues as of now