作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从我使用包装器的 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/
我是一名优秀的程序员,十分优秀!