Answer the question
In order to leave comments, you need to log in
How to use sched?
There is such a simple piece of code.
import sched, time
s = sched.scheduler(time.time, time.sleep)
def print_time(a='default'):
print("From print_time", time.time(), a)
def print_some_times():
tim = time.time()
# print(tim)
s.enter(10, 1, print_time)
s.enter(5, 2, print_time, argument=('positional',))
s.enter(5, 1, print_time, kwargs={'a': 'keyword'})
s.run()
print(time.time() - tim)
tim1 = time.time()
for i in range(5):
print_some_times()
print(time.time() - tim1)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question