How to restart tweepy script in case of error?

后端 未结 5 487
甜味超标
甜味超标 2020-12-13 16:37

I have a python script that continuously stores tweets related to tracked keywords to a file. However, the script tends to crash repeatedly due to an error appended below.

5条回答
  •  时光取名叫无心
    2020-12-13 17:24

    I have written a 2 process streaming using tweepy. It downloads, compresses and dumps the data into files which are rotated every hour. The program is restarted every hour and it can check the streaming process periodically to see if any new tweet is downloaded or not. If not it restarts the whole system.

    The code can be found here. Note that for compression it uses pipes. In case compression is not needed modifying the source is easy.

提交回复
热议问题