Python Forum

Full Version: Reconnect to an API?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone, my Python program connects to an API, is there any way to make it try and "auto reconnect" every 1 min to the said API if it gets disconnected?

My connection code is on a single thread.. so mechanically, I would need a way to just:

1. detect a disconnect, and
2. IF disconnect found, do a while loop on the thread.start()
3. untill connection restored?

This should be an interesting discussion and hopefully I learn alot from it but I am still pretty new, so simple explanations and code examples are the best Pray
So after some head aching searching, it seems the easiest way to do this is to have a totally separate script monitoring some type of connection, if the connection goes out, close the original script and re-run the original script after connection is restablished?