問題描述
我得到的錯誤是:
RuntimeWarning: coroutine 'StdOutListener.on_status' was never awaited
if self.on_status(status) is False:
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
我的 stdOutListener 看起來像這樣:
My stdOutListener looks like this:
class StdOutListener(StreamListener):
async def on_status(self, status):
channel = await bot.get_channel(64970710814)
await channel.send(status.text)
我知道我需要將 on_status 稱為 async'd,但我該怎么做呢?我已經嘗試等待 on_status 中的大部分內容
I understand that I need to get on_status called async'd, but how do I do this? I've tried awaiting most of the things inside on_status
推薦答案
Tweepy 還沒有 asyncio 支持.為此,請參閱 https://github.com/tweepy/tweepy/issues/732.
Tweepy doesn't yet have asyncio support. For that, see https://github.com/tweepy/tweepy/issues/732.
相反,您可以使用 is_async
參數在單獨的線程中運行流.請參閱 https://tweepy.readthedocs.io/en/latest/streaming_how_to.html#async-streaming.
Instead, you can use the is_async
parameter to run the stream in a separate thread.
See https://tweepy.readthedocs.io/en/latest/streaming_how_to.html#async-streaming.
這篇關于如何從 tweepy 異步 on_status?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!