Reputation: 136
I am using: django-rq: 0.9.6 rq_scheduler: 0.6.1
I am fairly new to docker and django_rq.
The issue that I am having is, my jobs are not executing or getting in the queue.
docker-compose.yml
redis:
container_name: projapi-redis
restart: always
image: redis:latest
ports:
- '6379:6379'
rq:
container_name: projapi-rq
build: .
command: python manage.py rqworker default
volumes:
- .:/src
links:
- redis
rqscheduler:
container_name: projapi-rqscheduler
build: .
command: python manage.py rqscheduler
volumes:
- .:/src
links:
- redis
settings.py
RQ_QUEUES = {
'default': {
'URL': 'redis://redis/0',
}
}
In the python shell, I ran :do_task.delay()
and the RQ Queues' finished jobs jumps up in number by a large amount. When I run: scheduler.schedule(datetime.utcnow(), 'do_task', interval=20)
, I don't get any response.
tasks.py
from django_rq import job, get_scheduler
from datetime import datetime
scheduler = get_scheduler()
@job
def do_delay_task():
return 'do_delay_task'
@job
def do_task():
return 'do a task'
do_delay_task.delay()
scheduler.schedule(datetime.utcnow(), 'do_task', interval=2000)
Upvotes: 1
Views: 1230
Reputation: 147
It is periodic task run, you forgot to run it:
scheduler.run()
also consider using of this module: https://github.com/rq/rq-scheduler
Upvotes: 1