<commit_before>"""
This example demonstrates the use of persistent job stores. On each run, it
adds a new alarm that fires after one minute. You can exit the program, restart
it and observe that any previous alarms that have not fired yet are still
active.
"""

from datetime import datetime, timedelta
import sys
import time

from apscheduler.scheduler import Scheduler
from apscheduler.jobstores.shelve_store import ShelveJobStore


def alarm(time):
    sys.stdout.write('Alarm! This alarm was scheduled at %s.\n' % time)


if __name__ == '__main__':
    scheduler = Scheduler()
    scheduler.add_jobstore(ShelveJobStore('example.db'), 'shelve')
    alarm_time = datetime.now() + timedelta(minutes=1)
    scheduler.add_date_job(alarm, alarm_time, name='alarm',
                           jobstore='shelve', args=[datetime.now()])
    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)<commit_msg>Fixed the persistent example (it wasn't closing the file properly when ctrl+C was pressed)<commit_after>"""
This example demonstrates the use of persistent job stores. On each run, it
adds a new alarm that fires after one minute. You can exit the program, restart
it and observe that any previous alarms that have not fired yet are still
active.
"""

from datetime import datetime, timedelta
import sys
import time

from apscheduler.scheduler import Scheduler
from apscheduler.jobstores.shelve_store import ShelveJobStore


def alarm(time):
    sys.stdout.write('Alarm! This alarm was scheduled at %s.\n' % time)


if __name__ == '__main__':
    scheduler = Scheduler()
    scheduler.add_jobstore(ShelveJobStore('example.db'), 'shelve')
    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()

    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()
{'fraction_non_alphanumeric': 0.087442218798151, 'fraction_numerical': 0.003852080123266564, 'mean_word_length': 3.5964601769911506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6575045', 'n_tokens_mistral': 763, 'n_tokens_neox': 736, 'n_words': 280}