'Python recursive limit and how to keep monitoring something

I am working on a python tkinter program that monitoring computer temperature, and I want it to update the temperature value after a fixed time. the following function is what I used to do that:

    def update():
        get_temp()#the function that get the computer temperature value, like cpu temperature.
        ...
    def upd():
        update()
        time.sleep(0.3)
        upd()#recursive call function.

    upd()

but this way will hit the recursive limit, so the program will stops after a period of time. I want it to keep updating the value, what should I do? I don't know if I change it to after() it will be better or not. but if I use after(), the tkinter window will freeze a while, so I don't want to use it. Thank you.



Solution 1:[1]

It needs loop. It should be:

def update():
    get_temp()#the function that get the computer temperature value, like cpu temperature.
    ...

def upd():
    while True:#needs a while true here and don't call upd() in this function.
        update()
        time.sleep(0.3)

upd()#this upd() is outside the function upd(),it used to start the function.

Thanks to everyone who helped me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Corporation