gpt4 book ai didi

python - 异步 - 运行时错误 : Timeout context manager should be used inside a task Unclosed client session

转载 作者:行者123 更新时间:2023-12-04 16:42:28 29 4
gpt4 key购买 nike

我正在尝试从我使用包装器的 api 获得一些响应。

我寻找更多错误,但他们没有解决我的问题。我不太了解等待函数或协程。我关闭了 is_asnyc,它有效,但我需要那个选项。所以我关不掉。

import clashroyale, asyncio
token = "my token"
cr = clashroyale.official_api.Client(token=token, is_async=True)

async def top():
p = await cr.get_top_players()
return p

topplayers = asyncio.run(top())

我排除了它只是从api获取信息但出现错误-

RuntimeError: Timeout context manager should be used inside a task
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001774361A3C8>

最佳答案

尝试在异步方法中移动客户端的初始化。它可能会尝试使用异步超时上下文管理器,并且由于您不在任务中,它会失败

关于python - 异步 - 运行时错误 : Timeout context manager should be used inside a task Unclosed client session,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57459823/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com