Python Forum
How to add a delay without using the sleep command
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add a delay without using the sleep command
#11
(Feb-03-2021, 07:08 PM)jefsummers Wrote: You probably want to have the part where you are checking the interrupter status where line 5 is. Also, rather than checking if finish is equal to time.time() as in your comment, you really want to use an inequality like in the code snippet.

Yeah the interrupter check being inside the while loop instead of having pass there was what did it for me. Took me forever to realize this but it certainly felt good when it worked. Also using "if time.time() == finish:
print("Number of interrupts: " + str(x))" worked for me.
Reply
#12
I wonder what you have as a timer increment. Checking for equality in floats is risky business. I would never depend on "if time.time() == finish:". It is far to easy to check just time just before and just after the finish time and miss time() == finish.
Reply
#13
import asyncio

async def main():
    print('Hello')
    await asyncio.sleep(1)
    print('world')

asyncio.run(main())
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020