utils.py 262 B

123456789101112131415
  1. # -*- coding: utf-8 -*-
  2. #!/usr/bin/env python
  3. import threading
  4. from uuid import uuid4
  5. local = threading.local()
  6. def generate_request_id():
  7. return str(uuid4())
  8. def get_current_request_id():
  9. return getattr(local, 'request_id', generate_request_id())