rq / rq-scheduler

A lightweight library that adds job scheduling capabilities to RQ (Redis Queue)
MIT License
1.45k stars 229 forks source link

func never fire #211

Open changyushun opened 5 years ago

changyushun commented 5 years ago

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 !

oxalorg commented 5 years ago

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?

taewookim commented 4 years ago

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

ronalddas commented 2 years ago

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

This should be mentioned in the Doc