Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sleep_cycle()
#1
sleep_cycle.py:
from time import sleep,time as secs

def sleep_cycle(*arg):
    """Sleep to an offset time cycle.
sleep_cycle(offset,cycle) returns time slept in seconds (float)."""
    # example: sleep to 15 minutes past the hour: sleep_cycle(3600,900)
    # example: sleep to noon: sleep_cycle(86400,43200)
    if arg:
        off = int(arg[0]*1000000000)
        cyc = int(arg[1]*1000000000) if len(arg)>1 else 0
        now = int(secs()*1000000000)
        if cyc:
            off = (off-now)%cyc
        off = off/1000000000
        sleep(off)
        return off
    else:
        return 0
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

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