utils.session
Session 管理
ApiConfig
Session
Session(*, credential: Credential | None = None, enable_sign: bool = False, **kwargs)
Bases: AsyncClient
Session 类,用于管理 QQ 音乐的登录态和 API 请求
Source code in qqmusic_api/utils/session.py
SessionManager
Session 管理类,负责管理不同事件循环的 Session
初始化 SessionManager
Source code in qqmusic_api/utils/session.py
get
get() -> Session
获取当前事件循环的 Session
Source code in qqmusic_api/utils/session.py
set
set(session: Session) -> None
设置当前事件循环的 Session(全局池)
Source code in qqmusic_api/utils/session.py
push_to_stack
push_to_stack(loop: AbstractEventLoop, session: Session) -> None
将 Session 推入当前事件循环的 async with 上下文栈
Source code in qqmusic_api/utils/session.py
pop_from_stack
pop_from_stack(loop: AbstractEventLoop) -> None
create_session
create_session(credential: Credential | None = None, enable_sign: bool = False) -> Session
创建新的 Session
Source code in qqmusic_api/utils/session.py
get_session
get_session() -> Session
set_session
set_session(session: Session) -> None
create_session
create_session(credential: Credential | None = None, enable_sign: bool = False) -> Session
创建新的 Session
PARAMETER | DESCRIPTION |
---|---|
credential
|
凭据
TYPE:
|
enable_sign
|
是否启用 sign
TYPE:
|
Source code in qqmusic_api/utils/session.py
set_session_credential
set_session_credential(credential: Credential)