I have a python script (running on Mac OS X) that needs to be restarted when the internet goes down. If the internet is down, I would like to kill the current script, wait for the internet to go back up, and then restart it. Or, if possible, restart the function from within.
The problematic section of the Python code is as follows:
import tweetstream
# ...
with tweetstream.FilterStream(username, password, track = words) as stream:
for tweet in stream:
db.tweets.save(tweet)
Currently, if the internet goes down, the stream stops and doesn't reconnect.