You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project that will consume a long-running twitter stream, and the documentation doesn't mention what will happen when a disconnect occurs. Looking at the code, a requests exception might get caught, at which point python-twitter would raise its own exception?
I want to be sure that I take the best approach for guaranteeing a re-connect after being disconnected.
I apologize if I overlooked anything in the documentation, or if this behaviour is inherent to requests in some way.
The text was updated successfully, but these errors were encountered:
No apologies necessary! I didn't know what would happen until you asked.
You can set the requests.Session timeout parameter with something like:
api=twitter.Api(
CONSUMER_KEY,
CONSUMER_SECRET,
ACCESS_TOKEN,
ACCESS_SECRET,
tweet_mode="extended",
timeout=3.0# three second timeout
)
at which point, if something goes wrong (your connection goes down) you'll get a ConnectionError, which you could catch. If your connection comes back up before you disconnect with a ConnectionError, you might see some other errors. In testing, I got the following:
I have a project that will consume a long-running twitter stream, and the documentation doesn't mention what will happen when a disconnect occurs. Looking at the code, a requests exception might get caught, at which point python-twitter would raise its own exception?
I want to be sure that I take the best approach for guaranteeing a re-connect after being disconnected.
I apologize if I overlooked anything in the documentation, or if this behaviour is inherent to
requests
in some way.The text was updated successfully, but these errors were encountered: