【发布时间】:2021-03-27 00:56:17
【问题描述】:
在python中使用websocket-client库时,on_message函数是否可以成为协程?
我有以下代码:
async def on_message(ws, message):
await get_balance() # runs an aiohttp get request
ws = websocket.WebSocketApp(data_feed,on_message=on_message)
ws.run_forever()
这给了我错误
RuntimeWarning: coroutine 'on_message' was never awaited
callback(self, *args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
我错过了什么吗?
提前致谢
【问题讨论】:
标签: python asynchronous websocket