Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

26 lines (19 sloc) 720 Bytes
"""
Demonstrates how to use the gevent compatible scheduler to schedule a job that executes on 3 second
intervals.
"""
from datetime import datetime
import os
from apscheduler.schedulers.gevent import GeventScheduler
def tick():
print('Tick! The time is: %s' % datetime.now())
if __name__ == '__main__':
scheduler = GeventScheduler()
scheduler.add_job(tick, 'interval', seconds=3)
g = scheduler.start() # g is the greenlet that runs the scheduler loop
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
# Execution will block here until Ctrl+C (Ctrl+Break on Windows) is pressed.
try:
g.join()
except (KeyboardInterrupt, SystemExit):
pass
You can’t perform that action at this time.