I'm using python-rq to enqueue background tasks and then attempting to check their status in my web app.
First I grab all the workers attached to the queue:
workers = rq.Worker.all(queue=queue)
Before starting a task there is a single worker with state idle
that looks like this:
pid : 9
job_class : <class 'rq.job.Job'>
queue_class : <class 'rq.queue.Queue'>
version : 1.4.2
python_version : 3.7.7 (default, Jun 9 2020, 17:58:51)
[GCC 8.3.0]
serializer : <class 'rq.serializers.DefaultSerializer'>
name : c3482062db0043ddb4ccc3cdeefb027b
queues : [Queue('training_tasks')]
_exc_handlers : []
default_result_ttl : 500
default_worker_ttl : 420
job_monitoring_interval : 30
_state : idle
_is_horse : False
_horse_pid : 0
_stop_requested : False
log : <Logger rq.worker (INFO)>
log_job_description : True
last_cleaned_at : None
successful_job_count : 0
failed_job_count : 0
total_working_time : 0
birth_date : 2020-06-29 15:45:25.704249
scheduler : None
disable_default_exception_handler : False
_job_id : None
last_heartbeat : 2020-06-29 15:45:25.712674
After I enqueue a job and it starts to be processed, the work begins and the state
updates to busy
.
pid : 9
job_class : <class 'rq.job.Job'>
queue_class : <class 'rq.queue.Queue'>
version : 1.4.2
python_version : 3.7.7 (default, Jun 9 2020, 17:58:51)
[GCC 8.3.0]
serializer : <class 'rq.serializers.DefaultSerializer'>
name : c3482062db0043ddb4ccc3cdeefb027b
queues : [Queue('training_tasks')]
_exc_handlers : []
default_result_ttl : 500
default_worker_ttl : 420
job_monitoring_interval : 30
_state : busy
_is_horse : False
_horse_pid : 0
_stop_requested : False
log : <Logger rq.worker (INFO)>
log_job_description : True
last_cleaned_at : None
successful_job_count : 0
failed_job_count : 0
total_working_time : 0
birth_date : 2020-06-29 15:45:25.704249
scheduler : None
disable_default_exception_handler : False
_job_id : b'a460194c-e0ac-4cc6-8d4d-41c62a2eca41'
last_heartbeat : 2020-06-29 15:46:47.185807
The docs state that the worker should have a current_job
property that can be inspected for e.g. meta data, but my workers don't have it. There is a job_id
that I guess I could use but I'd like to know why my worker doesn't have the properties that the docs say that it should.
(I'm using rq 1.4.2 and redis 3.5.3 running on gunicorn with gevent)