Mar-30-2021, 09:23 PM
I have a while loop that is happening every 30 seconds
Lets say I am printing ("Hello") every 30 secs.
"Hello" 00:30
"Hello" 01:00
"Hello" 01:30
ect ect.
If at a certain time, I want to add a "Hello, Patrick". How would I specify that with out just using another time.sleep timer. How do I not make it time based, like how do I make it "next while loop" no matter what the time different is. Because lets say if the trigger for my "Hello Patrick" happens at 1:15, and I want "Hello Patrick" to appear at 1:30 (the beginning of the 30 sec Hello loop).. I understand I can just time.sleep(15) or whatever. How do I not become dependent on time.
Like "when true: next while loop "hello patrick". No matter how many seconds untill it comes.
I'm sorry that was the best way I could describe what I am trying to do. That was the best way I could articulate it. The trigger to print "Hello Patrick" can happen at anytime in the 30 secs.
Talk soon thank you! Sorry, I tried my best to describe.
def modelTimer(): starttime = time.time() timeout = time.time() + 60*60*6.5 while time.time() <= timeout: model(app) time.sleep(30 - ((time.time() - starttime) % 30.0))Is there any way I can execute code on the beginning of the next while loop?
Lets say I am printing ("Hello") every 30 secs.
"Hello" 00:30
"Hello" 01:00
"Hello" 01:30
ect ect.
If at a certain time, I want to add a "Hello, Patrick". How would I specify that with out just using another time.sleep timer. How do I not make it time based, like how do I make it "next while loop" no matter what the time different is. Because lets say if the trigger for my "Hello Patrick" happens at 1:15, and I want "Hello Patrick" to appear at 1:30 (the beginning of the 30 sec Hello loop).. I understand I can just time.sleep(15) or whatever. How do I not become dependent on time.
Like "when true: next while loop "hello patrick". No matter how many seconds untill it comes.
I'm sorry that was the best way I could describe what I am trying to do. That was the best way I could articulate it. The trigger to print "Hello Patrick" can happen at anytime in the 30 secs.
Talk soon thank you! Sorry, I tried my best to describe.
