I am using django-request-id-logging for attaching a request id to logging messages belonging to one request. But since a request also uses asgiref’s async_to_sync to call group_send from django views, the thread local variable isn’t available to this subthread.
According to the documentation, it says “Threadlocals and contextvars values are preserved across the boundary in both directions.”. Does it mean that they are shared?, If they are, then why isn’t the channels logger not able to get the thread local request id inside the function called by group_send?.
Same issue with websocket connect too, The middleware (First in the MIDDLEWARES identifier in settings.py) creates a thread local variable, connect goes through the middleware first then to the sync consumer, but still not able to access thread local variables when doing logging.