'Why is the scheduled function never called?

I have this very simple code to initiate a scheduled task in the background but nothing gets printed:

def printit():
    print("Hello, World!")


scheduler = sched.scheduler(time.time, time.sleep)
scheduler.enter(2, 1, printit)
scheduler.run(blocking=False)

while True:
    time.sleep(1)

It works if I set blocking to true. Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source