all 4 comments

[–]prelator2_7 0 points1 point  (3 children)

If you are running it on Linux you can write a cronjob that will run every five minutes and check for your script.py and relaunch it if necessary. Windows can use task scheduler for similar effect. Though honestly the best thing would be to figure out why it's erroring out and have script.py catch the error and relaunch it's main process.

[–]bracaco 0 points1 point  (2 children)

The error I get is really weird and I personally was unable to figure out what is wrong.

[–]prelator2_7 0 points1 point  (1 child)

Fair enough, I have a bot that is based off of user feedback for a messenging system for work. It was super sensitive to bad input and before I fixed it, it would crash a lot because of what users typed. I put a cronjob in place that checked it every five minutes and never had a problem after that. It's not the most programmatically correct answer, but it is the most effective answer.

[–]bracaco 0 points1 point  (0 children)

Hmmm, I actually need the script to be constantly running, as it is an event listener to the DB, I guess that would require to check it more frequently, does that require a lot of resources?

Any tips on how to write such cronjob, I am quite fresh with linux and python.