2024-07-05 06:32:00 +00:00
|
|
|
from threading import local
|
|
|
|
|
|
|
|
_thread_locals = local()
|
|
|
|
|
|
|
|
def get_current_request():
|
|
|
|
return getattr(_thread_locals, 'request', None)
|
|
|
|
|
|
|
|
def set_current_request(request):
|
|
|
|
_thread_locals.request = request
|
2024-07-05 13:14:47 +00:00
|
|
|
|
|
|
|
def set_current_trace_id(trace_id):
|
|
|
|
_thread_locals.trace_id = trace_id
|
|
|
|
|
|
|
|
def get_current_trace_id():
|
|
|
|
return getattr(_thread_locals, 'trace_id', None)
|