diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2012-03-17 20:58:38 +0200 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2012-03-17 20:58:38 +0200 |
commit | 93a696d841d43169bdac14531d671c4c4bd6010c (patch) | |
tree | 1f1babfd89088ee25646cc77fd0c60dd4cd095ad /examples | |
parent | abc6cb225976ef623716e4e78bbd484c1e987826 (diff) | |
download | apscheduler-93a696d841d43169bdac14531d671c4c4bd6010c.tar.gz |
Fixed the persistent example (it wasn't closing the file properly when ctrl+C was pressed)
Diffstat (limited to 'examples')
-rw-r--r-- | examples/persistent.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/examples/persistent.py b/examples/persistent.py index 1e77d1b..99993e1 100644 --- a/examples/persistent.py +++ b/examples/persistent.py @@ -23,11 +23,16 @@ if __name__ == '__main__': alarm_time = datetime.now() + timedelta(minutes=1) scheduler.add_date_job(alarm, alarm_time, name='alarm', jobstore='shelve', args=[datetime.now()]) + scheduler.print_jobs() sys.stdout.write('To clear the alarms, delete the example.db file.\n') sys.stdout.write('Press Ctrl+C to exit\n') scheduler.start() - # This is here to prevent the main thread from exiting so that the - # scheduler has time to work -- this is rarely necessary in real world - # applications - time.sleep(9999) + try: + # This is here to prevent the main thread from exiting so that the + # scheduler has time to work -- this is rarely necessary in real world + # applications + time.sleep(9999) + finally: + # Shut down the scheduler so that the job store gets closed properly + scheduler.shutdown() |