python-twitter
python-twitter copied to clipboard
`create_tweet` is throwing Connection Error
I am not able to tweet.
I have a script (main.py) to tweet 3 times a day and after tweeting single time api.create_tweet
throw ConnectionError
.
You may check the network to connect the twitter services.:)
you mean internet ?
yes, you can check it.
it is running on Azure vm. i have fix this by re trying to tweet when it throws error. see.
try:
api.create_tweet(text=hero_text)
except:
print(f"on verse: {current_verse_id} at create_tweet something went wrong, Retrying again... - {time.strftime('%X %x %Z')}")
try:
api.create_tweet(text=hero_text)
except:
print(f"Fail again! - {time.strftime('%X %x %Z')}")
else:
print(f"Tweet Send on second try for verse {current_verse_id} - {time.strftime('%X %x %Z')}")
else:
print(f"Tweet Send for verse {current_verse_id} - {time.strftime('%X %x %Z')}")
it works on trying again just after exception.
Internet is not the problem.
I have test some tweets, and not found this issue, I guess there may have some connection errors on the vm. :)
You shouldn't wrap the exception to the specific string like: except: print... when you not sure what is the type of that exception. In this case, you should raise the full exception and bring it on here, so others can help you if they can.