twikit icon indicating copy to clipboard operation
twikit copied to clipboard

“Event loop is closed” will be reported when failed to access twitter

Open dengsong-yang opened this issue 11 months ago • 2 comments

version: 2.20

use asyncio , “Event loop is closed” will be reported when failed to access twitter

example:

async def get_latest_tweet(USER_ID, TYPE) -> Tweet:
    tweets = await client.get_user_tweets(user_id=USER_ID, tweet_type=TYPE, count=10)
    if tweets:
        return tweets
    return None


if __name__ == '__main__':
    while True:
        try:
            asyncio.run(get_latest_tweet("1517030962764214272", "Tweets"))
        except Exception as e:
            print(e)
            continue

Image

dengsong-yang avatar Jan 23 '25 10:01 dengsong-yang

sent full traceback please

dwqekc avatar Apr 20 '25 16:04 dwqekc

and guy u need run this shit(get_latest_tweet) with one future

dwqekc avatar Apr 20 '25 20:04 dwqekc