import threading class RequestContext: _thread_local = threading.local() @classmethod def set_error_id(cls, error_id): cls._thread_local.error_id = error_id @classmethod def get_error_id(cls): return getattr(cls._thread_local, "error_id", None)