asgiref icon indicating copy to clipboard operation
asgiref copied to clipboard

@sync_to_async(thread_sensitive=True)

Open kbhalerao opened this issue 5 years ago • 6 comments

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

kbhalerao avatar Apr 12 '20 02:04 kbhalerao

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.

adamchainz avatar Apr 12 '20 10:04 adamchainz

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.

andrewgodwin avatar Apr 12 '20 16:04 andrewgodwin

I opened a PR to remove the doc example here: https://github.com/django/django/pull/12706

andrewgodwin avatar Apr 12 '20 16:04 andrewgodwin

Happy to include support for doing this, as a part of https://github.com/django/asgiref/pull/159, or once its merged in.

devxpy avatar May 13 '20 16:05 devxpy

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.

andrewgodwin avatar May 14 '20 05:05 andrewgodwin

Still having the issues as of now

updatedennismwangi avatar Aug 30 '20 15:08 updatedennismwangi