rq / rq-scheduler

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

Remove jobs after completion #192

Closed GasparPizarro closed 5 years ago

GasparPizarro commented 6 years ago

I have a job created with enqueue_at (using Django and django-rq)

scheduler = django_rq.get_scheduler("my_queue")
scheduler.enqueue_at(the_date, func, job_id=my_custom_id)

and I have two processes, an rqworker my_queue and rqscheduler. When I schedule the jobs they execute and

However, every time I run rqscheduler all the already done jobs are run, regardless of their date or whether they have been executed, as the rqworker shows:

 Job OK (28be8399-5038-4a37-9d80-90c8fd40781f)

However, every time I run the scheduler it runs all old jobs, regardless of whether they have been run before.

(env) my_computer$ rqscheduler -v
10:51:50 Registering birth
10:51:50 Entering run loop
10:51:50 Checking for scheduled jobs
10:51:50 Pushing 493bbea3-c653-471d-b6ba-73c3f96287a9 to refill
10:51:50 Pushing 503075f5-658d-4e88-830e-711ed4477400 to refill
10:51:50 Pushing 28be8399-5038-4a37-9d80-90c8fd40781f to refill
10:51:50 Sleeping 60.00 seconds
[CTRL-C]
10:51:53 Shutting down RQ scheduler...
10:51:53 Registering death
10:51:53 Registering death
(env) my_computer$ rqscheduler -v
10:51:54 Registering birth
10:51:54 Entering run loop
10:51:54 Checking for scheduled jobs
10:51:54 Pushing 493bbea3-c653-471d-b6ba-73c3f96287a9 to refill
10:51:54 Pushing 503075f5-658d-4e88-830e-711ed4477400 to refill
10:51:54 Pushing 28be8399-5038-4a37-9d80-90c8fd40781f to refill
10:51:54 Sleeping 60.00 seconds

Is this expected behavior? How do I do to have the scheduled jobs run only once?

selwin commented 5 years ago

You can specify how many times the job should be repeated through the repeat parameter https://github.com/rq/rq-scheduler#periodic--repeated-jobs