开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜