use asyncio , “Event loop is closed” will be reported when failed to access twitter
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
version: 2.20
use asyncio , “Event loop is closed” will be reported when failed to access twitter
example: