zsoldosp / django-currentuser

Conveniently store reference to request user on thread/db level.
BSD 3-Clause "New" or "Revised" License
157 stars 40 forks source link

Should we be using asgiref.local.Local if available for import? #51

Open jacklinke opened 3 years ago

jacklinke commented 3 years ago

With django now supporting async, should we be trying to import asgiref.local.Local if available, which is a drop-in async replacement for threading.local?

Perhaps replacing:

from threading import local

With:

try:
    from asgiref.local import Local as local
except ImportError:
    from threading import local

Would be happy to make a PR for this, but not sure how to approach the situation where asgiref package is available vs when it is not.