rq-scheduler icon indicating copy to clipboard operation
rq-scheduler copied to clipboard

func never fire

Open changyushun opened this issue 5 years ago • 3 comments

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 !

changyushun avatar Oct 03 '19 01:10 changyushun

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?

oxalorg avatar Oct 11 '19 11:10 oxalorg

The rqschdulers only schedules. You have to start the RQ worker

taewookim avatar Apr 27 '20 18:04 taewookim

The rqschdulers only schedules. You have to start the RQ worker

This should be mentioned in the Doc

ronalddas avatar Sep 20 '22 09:09 ronalddas