Run Script with probability of failure in Python every second

0

Good afternoon, classmates.

I am relatively new to programming and I developed my first Bot for some tasks, it is already finished but I have a small problem to execute it constantly since it occasionally fails for a foreign reason (sometimes the server does not send the information and the program falls, this happened to me every 5-6hs when it includes the code in a While) but it is essential that when it falls it is "reactivated", so I found the following solutions:

1) Use Contrab and modify it so that it runs every 1 second 2) The following solution: Run script in python every second

My doubt with the second solution, is if the program falls, does this second also fall? If so, it would not be what I was looking for. I appreciate any kind of response that guides me to what is the most indicated for this solution, in a summarized way execute every 1 second or less a script that occasionally fails.

Thanks

    
asked by Nicanor Medina 10.04.2018 в 00:17
source

1 answer

0

You can use supervisord is very good when you want them to run Automatically tasks and if they fail, the same thing to do it again, you can also configure a notification via Email with superlance , in your file supervisord.conf with this configuration

[eventlistener:crashmail]
command=/usr/local/bin/crashmail -a -m [email protected]
events=PROCESS_STATE

If you want some extra configuration, you can use this reference Get notification from supervisor when a job exits

    
answered by 10.04.2018 в 19:47