luren-dc / QQMusicApi

Python QQ音乐Api封装库
MIT License
54 stars 15 forks source link

Unclosed client session #2

Closed liuhangbin closed 7 months ago

liuhangbin commented 8 months ago

#!/bin/env python3

import asyncio
from pyqqmusicapi import QQMusic

async def async_main():
    # 初始化Api,可传入musicid,musickey
    api = QQMusic()

    # 可用api:SongApi,TopApi,SearchApi,MvApi,PlaylistApi,AlbumApi,LoginApi
    result = await api.song.detail("0039MnYb0qxYhV")

    song_name = result['track_info']['info']['name']
    time_public = result['track_info']['info']['timePublic']
    album_name = result['track_info']['album']['name']
    print(f"{song_name}, album {album_name}, public {time_public}")

asyncio.run(async_main())

执行后返回错误

晴天, album 叶惠美, public 2003-07-31
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fa8c3175950>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7fa8c238c050>, 2580.640299335)]']
connector: <aiohttp.connector.TCPConnector object at 0x7fa8c3134f50>

我看 pyqqmusicapi/qqmusic.py 有定义 def __clean(). 是我代码少了 close session 吗?

luren-dc commented 7 months ago

原本是想要复用aiohttp.seesion,但是相关资料较少,可能出错了

luren-dc commented 7 months ago

目前没有问题了