from apscheduler.schedulers.background import BackgroundScheduler
def my_task1():
print ("Task 1")
def my_task2():
print ("Task 2")
if __name__ == '__main__':
process_scheduler = BackgroundScheduler()
process_scheduler.add_job(my_task1, 'cron', id='my_task1', seconds=5)
process_scheduler.add_job(my_task2, 'cron', id='my_task2', seconds=10)
process_scheduler.start()
atexit.register(lambda: process_scheduler.shutdown())