I want to set timer in a thread and kill that thread when I want to unset the timer set by gobject.timeout_add, is this a good way to do this?
basically I want to run a function for every 180 seconds but I want to be able to stop it whenever I want to(called from another function). How to achieve this properly?
I have read that killing a thread is bad! How bad is it for simple tasks like this?
According to the docs when you call
gobject.timeout_addit returns aintwhich is unique for that timeout source. And then also farther down in the docs, you see a function calledgobject.source_removewhich takes, as an argument, anintthat will remove the event source for you without having to mess with threads and the like.Example:
Hope that helps!