__init__.py 587 B

123456789101112131415161718192021222324
  1. from .base import AbstractSession
  2. from .asyncbased import AsyncBasedSession
  3. from .threadbased import ThreadBasedWebIOSession
  4. _session_type = AsyncBasedSession
  5. def set_session_implement(session_type):
  6. global _session_type
  7. assert session_type in [ThreadBasedWebIOSession, AsyncBasedSession]
  8. _session_type = session_type
  9. def get_session_implement():
  10. global _session_type
  11. return _session_type
  12. def get_current_session() -> "AbstractSession":
  13. return _session_type.get_current_session()
  14. def get_current_task_id():
  15. return _session_type.get_current_task_id()