Skip to content

Instantly share code, notes, and snippets.

View apscheduler_test.log
2022-08-06 22:59:31,316: apscheduler.scheduler:base - add_job: Adding job tentatively -- it will be properly scheduled when the scheduler starts
2022-08-06 22:59:31,316: root:scheduler - schedule_function_1: scheduled_job: function_1 (trigger: date[2022-08-06 15:00:31 UTC], pending)
2022-08-06 22:59:31,316: root:scheduler - <module>: Starting main scheduling loop
2022-08-06 22:59:32,646: apscheduler.scheduler:base - _real_add_job: Added job "function_1" to job store "default"
2022-08-06 22:59:32,647: apscheduler.scheduler:base - start: Scheduler started
2022-08-06 22:59:32,647: apscheduler.scheduler:base - _process_jobs: Looking for jobs to run
2022-08-06 22:59:33,120: apscheduler.scheduler:base - _process_jobs: Next wakeup is due at 2022-08-06 15:00:31.053049+00:00 (in 58.405645 seconds)
2022-08-06 23:00:31,524: apscheduler.scheduler:base - _process_jobs: Looking for jobs to run
2022-08-06 23:00:32,019: apscheduler.executors.default:base - run_job: Running job "function_1 (trigger: date[2022-08-06 15:00:31 U
View functions.py
from scheduler import schedule_function_2
from logger import log
import time
def function_1():
log.info(f'This job does some work in function_1')
time.sleep(15)
View logger.py
import logging
import sys
log = logging.getLogger()
log.setLevel(level=logging.DEBUG)
logFormatter = logging.Formatter('%(asctime)s: %(name)s:%(module)s - %(funcName)s: %(message)s')
consoleHandler = logging.StreamHandler(sys.stdout)
consoleHandler.setFormatter(logFormatter)
View scheduler.py
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.executors.pool import ThreadPoolExecutor
from datetime import datetime, timedelta
import os
import sys
from logger import log
View apscheduler_logtest.log
2022-08-05 09:25:49,476: INFO apscheduler_logtest - <module>: Logging system has been initialized
2022-08-05 09:25:49,844: INFO base - add_job: Adding job tentatively -- it will be properly scheduled when the scheduler starts
2022-08-05 09:25:49,845: INFO apscheduler_logtest - <module>: Press Ctrl+C
2022-08-05 09:25:49,846: INFO base - _real_add_job: Added job "tick" to job store "default"
2022-08-05 09:25:49,846: INFO base - start: Scheduler started
2022-08-05 09:25:49,846: DEBUG base - _process_jobs: Looking for jobs to run
2022-08-05 09:25:49,846: DEBUG base - _process_jobs: Next wakeup is due at 2022-08-05 09:25:52.844546+08:00 (in 2.998023 seconds)
2022-08-05 09:25:52,848: DEBUG base - _process_jobs: Looking for jobs to run
2022-08-05 09:25:52,850: DEBUG base - _process_jobs: Next wakeup is due at 2022-08-05 09:25:55.844546+08:00 (in 2.995660 seconds)
2022-08-05 09:25:52,871: INFO apscheduler_logtest - tick: Tick: 2022-08-05 01:25:52.871458
View apscheduler_logtest.py
import logging
import sys
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
logFormatter = logging.Formatter('%(asctime)s: %(levelname)8s %(module)8s - %(funcName)s: %(message)s')
consoleHandler = logging.StreamHandler(sys.stdout)
consoleHandler.setFormatter(logFormatter)
View apscheduler_not_working.log
/Users/selim/Developer/worker_queue_test/venv/bin/python "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 54278 --file /Users/selim/Developer/worker_queue_test/apscheduler_based/clock.py
Connected to pydev debugger (build 221.6008.17)
2022-07-27 17:14:24,798: DEBUG clock - log_debug: REDIS URL: rediss://:381c74f136d4401b88db24c1c8a2827b@us1-adequate-jaguar-37699.upstash.io:37699
2022-07-27 17:14:24,798: DEBUG clock - log_debug: redis_ssl_verify: required
2022-07-27 17:14:24,857: INFO clock - log_info: Starting __main__ program loop.
2022-07-27 17:14:24,857: INFO clock - log_info: Adding listeners
2022-07-27 17:14:24,857: DEBUG clock - log_debug: Execution Listener flag names: EVENT_JOB_EXECUTED, EVENT_JOB_ERROR
2022-07-27 17:14:24,857: DEBUG clock - log_debug: Management Listener flag names: EVENT_JOB_ADDED, EVENT_JOB_REMOVED, EVENT_JOB_MODIFIED, EVENT_JOB_SUBMITTED
2022-07-27 17:1
View apscheduler_working.log
/Users/selim/Developer/worker_queue_test/venv/bin/python "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 54240 --file /Users/selim/Developer/worker_queue_test/apscheduler_based/clock.py
Connected to pydev debugger (build 221.6008.17)
2022-07-27 17:08:59,527: DEBUG clock - log_debug: REDIS URL: rediss://localhost:6380
2022-07-27 17:08:59,527: DEBUG clock - log_debug: redis_ssl_verify: none
2022-07-27 17:08:59,588: INFO clock - log_info: Starting __main__ program loop.
2022-07-27 17:08:59,588: INFO clock - log_info: Adding listeners
2022-07-27 17:08:59,588: DEBUG clock - log_debug: Execution Listener flag names: EVENT_JOB_EXECUTED, EVENT_JOB_ERROR
2022-07-27 17:08:59,588: DEBUG clock - log_debug: Management Listener flag names: EVENT_JOB_ADDED, EVENT_JOB_REMOVED, EVENT_JOB_MODIFIED, EVENT_JOB_SUBMITTED
2022-07-27 17:08:59,588: INFO clock - log_info: Adding scheduled jobs
2022
@HanSooloo
HanSooloo / apscheduler_test.py
Created Jul 27, 2022
apscheduler test program
View apscheduler_test.py
import random
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.executors.pool import ThreadPoolExecutor
import apscheduler.events as events
from apscheduler_event_types import event_code, EventCode
@HanSooloo
HanSooloo / clock.py
Created Jul 25, 2022
Testing with apscheduler
View clock.py
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.executors.pool import ThreadPoolExecutor
import apscheduler.events as events
# This file has a dictionary that maps the apscheduler event codes to actual text values
# e.g., {512: 'EVENT_JOB_ADDED'}
from apscheduler_event_types import event_code