zsoldosp / django-currentuser

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

Should this be using asgiref.local.Local? #77

Open uptickmetachu opened 2 months ago

uptickmetachu commented 2 months ago

With django being used in more async contexts should the threading local _thread_locals swap to using asgiref.local.Local?

zsoldosp commented 2 months ago

@uptickmetachu I don't have active django projects with async, so don't have the immediate need for it

If you could adjust the tests and add async testcases to it (tests/testapp/tests.py, based on TestUserBase, TestSetUserToThread, CurrentUserFieldOnUpdateTestCase just create the async variant), I could take a look

Also, in non-django contexts I recall we used contextvars, which would have the benefit of having a single implementation that works both with sync and async setups. What do you think?