django-log-request-id
django-log-request-id copied to clipboard
Use `ContextVar` instead of `threading.local`
I believe switching to using contextvar lib would allow tracking request ID through asynchronous contexts, like when using Daphne + ASGI
see https://docs.python.org/3/library/contextvars.html#asyncio-support for example
Hi,
We're already using asgiref.local.Local where available (asgiref is now a dependency of all supported versions of Django). See https://github.com/dabapps/django-log-request-id/blob/master/log_request_id/init.py#L7
asgiref uses contextvars internally: https://github.com/django/asgiref/blob/main/asgiref/local.py
Okay, you can update your README. It still says you're using threading.local and asks for suggestions
Oh good catch!
fwiw, it still still says that :P