regarding the usage of apscheduler through python

124 views
Skip to first unread message

eluru kamalaswarnitha

unread,
Mar 1, 2021, 7:11:37 AM3/1/21
to APScheduler
Hi,
My doubt is how to store the job details in redis jobstore.
And also is there any way to get the job details through an api?
My code is :
from apscheduler.schedulers.blocking import BlockingScheduler
import datetime
from apscheduler.jobstores.redis import RedisJobStore

def cron_process():
    print ('periodic print')
def corn(name):
print('hello {}'.format(name))
scheduler = BlockingScheduler()
scheduler.add_job(cron_process, 'date',id='job1')
scheduler.add_job(corn,'date',args=['world'],id='job2')
print(scheduler.get_jobs())

scheduler.start()

Alex Grönholm

unread,
Mar 1, 2021, 7:42:08 AM3/1/21
to apsch...@googlegroups.com

Have you read the documentation here? https://apscheduler.readthedocs.io/en/stable/userguide.html#configuring-the-scheduler

You need to instantiate the RedisJobStore class and configure the scheduler to use it:

jobstores = {

    'default': RedisJobStore()

}
scheduler = BlockingScheduler(jobstores=jobstores)

Note that until the scheduler starts, get_jobs() will only show the tentatively schedule jobs (those awaitin to be added to the store), and not the jobs currently in the job store.

--
You received this message because you are subscribed to the Google Groups "APScheduler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/d2fe7b63-8506-476b-9d01-f4206b0611bcn%40googlegroups.com.

eluru kamalaswarnitha

unread,
Mar 2, 2021, 7:39:30 AM3/2/21
to apsch...@googlegroups.com
Hi I have tried like this but not able to store in my local redis db.Facing errors can you help in detail

my code is:
-----------------------------
from apscheduler.schedulers.blocking import BlockingScheduler
import datetime
from apscheduler.jobstores.redis import RedisJobStore


class Job():
RedisJobStore(db=0, jobs_key='apscheduler_jobs', run_times_key='apschedulerrun_times', host='127.0.0.1',port=6379)


 
jobstores = {

    'default': RedisJobStore()


}
def cron_process():
    print ('periodic print')
def corn(name):
print('hello {}'.format(name))
scheduler = BlockingScheduler(jobstores=jobstores)
scheduler.add_job(cron_process, 'date',id='job1',jobstore='redis')#,jobstore='apscheduler_jobs')
scheduler.add_job(corn,'date',args=['world'],id='job2',jobstore='redis')#,jobstore='apscheduler_jobs')
#scheduler.add_jobstore()
print("@@",scheduler.get_jobs())
scheduler.start()
print(scheduler.get_jobs())

is there a correct syntax to pass arguments into scheduler.add_jobstore()
as like for add_job(functionname,trigger,args)

please help me in using jobstores for the scheduled jobs .i must be able to monitor the scheduled job details in the redis database.

Alex Grönholm

unread,
Mar 2, 2021, 8:41:00 AM3/2/21
to apsch...@googlegroups.com

Were you not able to find this in the API documentation? https://apscheduler.readthedocs.io/en/stable/modules/schedulers/base.html#apscheduler.schedulers.base.BaseScheduler.add_jobstore

Also, I cannot read your mind so you need to tell me what errors you are getting.

The code you pasted is not even syntactically valid. Can you provide me a script that reproduces the error(s)?

Reply all
Reply to author
Forward
0 new messages