Feb-18-2021, 06:00 PM
Hello.I have the following function:
So, I want to pass a parameter in TaskManager function ,fox example I want to pass number 5, in order to wait for 5 seconds.
I tried to do this one:
I understand why the code is not working(because recursion never finishes)
I want to do something for a few seconds(for example) without interrupt the whole code like time.sleep().
I want something like millis() function from arduino( if you know).
How can I do this?
Thanks
from threading import Timer a = 0 def TaskManager(): global a t = Timer( 1, TaskManager ) t.start() if(a == 5): t.cancel() return print("hello") a += 1 TaskManager()I don't want to use time.sleep.
So, I want to pass a parameter in TaskManager function ,fox example I want to pass number 5, in order to wait for 5 seconds.
I tried to do this one:
from threading import Timer def TaskManager(delay_time): t = Timer( 1 , TaskManager [delay_time]) t.start() if(delay_time == 0): t.cancel() return print("hello") delay_time -= 1 TaskManager(5)in order to delay for 5 sec. but I do not want interruption (like time.sleep() ).
I understand why the code is not working(because recursion never finishes)
I want to do something for a few seconds(for example) without interrupt the whole code like time.sleep().
I want something like millis() function from arduino( if you know).
How can I do this?
Thanks