开发者

Send alert (mail) if a process (python code) takes more than specified time to execute

开发者 https://www.devze.com 2023-01-29 10:33 出处:网络
I need to send an alert (mail) if a process (python code开发者_StackOverflow) takes more than 5 minutes to execute, and also process should continue to run after sending alert !! I am using time.time(

I need to send an alert (mail) if a process (python code开发者_StackOverflow) takes more than 5 minutes to execute, and also process should continue to run after sending alert !! I am using time.time() for timer, How can it be implemented ?


I don't know how to implement it using time.time(), but I suggest that you look at the signal module. First thing you need to do is to set up the handler via signal.signal(signal.SIGALRM, your_signal_handler_function), and then schedule the SIGALARM to be sent to your process in 300 seconds via signal.alarm(300).

This will work only on Unix, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消