Skip to content

Instantly share code, notes, and snippets.

@woodRock
Last active August 28, 2018 08:38
Show Gist options
  • Save woodRock/b67d2114e36ca87efc00d124c8f8af92 to your computer and use it in GitHub Desktop.
Save woodRock/b67d2114e36ca87efc00d124c8f8af92 to your computer and use it in GitHub Desktop.
Implement a job scheduler which takes in a function f and an integer n, and * calls f after n milliseconds.
import sched, time
s = sched.scheduler(time.time, time.sleep)
def print_time(): print ("From print_time", time.time())
def job_scheduler(f,n):
s.enter(n, 1, f, ())
s.run()
job_scheduler(print_time, 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment