solarwind
February 29th, 2008, 02:02 AM
Hey all,
I wrote a pyGTK program (written in Python) that uses gobject loops to execute a function every 60 seconds. However, there may be cases where the function gets stuck up somewhere and needs to be killed and restarted. What's the best way to keep a check on this? Would a watchdog type method work?
I was thinking along the lines of adding another gobject loop that runs a function every five minutes that removes the old gobject loop (the one that runs every 60 seconds) and adds it again. In that way, it's guaranteed to be restarted at least every five minutes. I know this is a very crude way but I can't think of any other method. I'm new to GTK and GOBJECT so any help would be much appreciated.
By the way, the program is a python mail checker that sits in the system tray. What happens is, sometimes (due to a bad internet connection), the connection times out or disconnects and reconnects. In this case, the mail checking function freezes up or crashes and the program just sits there doing nothing and I don't get notifications. However, restarting the program works but I don't want to have to keep an eye out for the program. It's supposed to be watching out for me!
I will gladly post the source code if anyone is willing to help me.
I wrote a pyGTK program (written in Python) that uses gobject loops to execute a function every 60 seconds. However, there may be cases where the function gets stuck up somewhere and needs to be killed and restarted. What's the best way to keep a check on this? Would a watchdog type method work?
I was thinking along the lines of adding another gobject loop that runs a function every five minutes that removes the old gobject loop (the one that runs every 60 seconds) and adds it again. In that way, it's guaranteed to be restarted at least every five minutes. I know this is a very crude way but I can't think of any other method. I'm new to GTK and GOBJECT so any help would be much appreciated.
By the way, the program is a python mail checker that sits in the system tray. What happens is, sometimes (due to a bad internet connection), the connection times out or disconnects and reconnects. In this case, the mail checking function freezes up or crashes and the program just sits there doing nothing and I don't get notifications. However, restarting the program works but I don't want to have to keep an eye out for the program. It's supposed to be watching out for me!
I will gladly post the source code if anyone is willing to help me.