rq-scheduler
rq-scheduler copied to clipboard
func never fire
hello all below is my simple test but the func never fire. what am i miss ? step 1 :
from redis import Redis
from rq import Queue
from rq_scheduler import Scheduler
from datetime import datetime
def job_func():
f = open('log.txt','a+')
f.write("hello world\r\n")
print('job fire')
redis = Redis(host='localhost',port=6379,db=0)
redis.set('name','sam')
print(redis.get('name'))
print(redis)
scheduler = Scheduler(connection=redis)
scheduler.schedule(
scheduled_time=datetime.utcnow(), # Time for first execution, in UTC timezone
func=job_func, # Function to be queued
args=['hello', 'world'], # Arguments passed into function when executed
kwargs={'foo': 'bar'}, # Keyword arguments passed into function when executed
interval=10, # Time before the function is called again, in seconds
repeat=5, # Repeat this number of times (None means repeat forever)
meta={'foo': 'bar'} # Arbitrary pickleable data on the job itself
)
print('script done')
step 2: after run this python script then run rqscheduler
rqscheduler --host localhost --port 6379 --db 0
and return Registering birth
message.
but my func that simple append text to file never fire !
Scheduler will only schedule the job to a queue. Did you make sure you have the default
rq (queue) running with the same redis db?
The rqschdulers only schedules. You have to start the RQ worker
The rqschdulers only schedules. You have to start the RQ worker
This should be mentioned in the Doc