How do I async on_status from tweepy?

自古美人都是妖i 提交于 2020-12-13 06:30:13

问题


The error I'm getting is:

RuntimeWarning: coroutine 'StdOutListener.on_status' was never awaited
if self.on_status(status) is False:
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

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)

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


回答1:


Tweepy doesn't yet have asyncio support. For that, see https://github.com/tweepy/tweepy/issues/732.

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.



来源:https://stackoverflow.com/questions/59125640/how-do-i-async-on-status-from-tweepy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!