sbt-idp/cope2n-api/fwd_api/middleware/local_storage.py

15 lines
363 B
Python
Raw Permalink Normal View History

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)