RQ-dashboard reports empty time data

Viewed 772

I'm trying to build a job queue with Redis Queue and RQ-scheduler. But from RQ-dashboard I get the following error when I try to load the jobs tab. I see that the jobs are added because the job count is going up.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/rq_dashboard/web.py", line 101, in _wrapped
    result_dict = f(*args, **kwargs)
  File "/rq_dashboard/web.py", line 428, in list_jobs
    queue_name, registry_name, offset, per_page
  File "/rq_dashboard/web.py", line 233, in get_queue_registry_jobs_count
    current_queue_jobs = [queue.fetch_job(job_id) for job_id in job_ids]
  File "/rq_dashboard/web.py", line 233, in <listcomp>
    current_queue_jobs = [queue.fetch_job(job_id) for job_id in job_ids]
  File "/usr/local/lib/python3.7/site-packages/rq/queue.py", line 147, in fetch_job
    job = self.job_class.fetch(job_id, connection=self.connection)
  File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 299, in fetch
    job.refresh()
  File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 506, in refresh
    self.restore(data)
  File "/usr/local/lib/python3.7/site-packages/rq/job.py", line 474, in restore
    self.started_at = str_to_date(obj.get('started_at'))
  File "/usr/local/lib/python3.7/site-packages/rq/utils.py", line 256, in str_to_date
    return utcparse(as_text(date_str))
  File "/usr/local/lib/python3.7/site-packages/rq/utils.py", line 172, in utcparse
    return datetime.datetime.strptime(string, '%Y-%m-%dT%H:%M:%SZ')
  File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
    (data_string, format))
ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%SZ'
23:48:49: Exception on /0/data/jobs/default/queued/8/1.json [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/rq/utils.py", line 169, in utcparse
    return datetime.datetime.strptime(string, _TIMESTAMP_FORMAT)
  File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
    (data_string, format))
ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

I add the jobs as follows:

from redis import Redis
from rq import Queue
from rq_scheduler import Scheduler
from datetime import datetime
import functions

tables = [["materialen", 2260, "artikelcode"], ["contracten", 4200, "contractnummer"], ["klantgegevens", 101, "klantnummer"], ["servicebonnen", 3600, "servicebonnummer"], [
    "contactpersonen", 105, "klantnummer"], ["archief", 3900, "servicebonnummer"], ["documenten", 4240, "volgnummer"], ["memos", 3609, "servicebonnummer"]]

# Get a scheduler for the "default" queue
scheduler = Scheduler(connection=Redis('127.0.0.1'))

for tableInfo in tables:
    scheduler.schedule(
        scheduled_time=datetime.utcnow(),
        timeout=120,
        description=tableInfo[0],
        func=functions.updateTable,
        args=[tableInfo],
        interval=60,
        repeat=None,
    )

I can't figure out what I'm doing wrong? What variable is empty or do I set the scheduled time incorrectly?

1 Answers

The issue is because rq-dashboard relies on rq v1.3.0 and it looks like it has some API differences from rq v1.4.0+. So, ideally this should be fixed by rq-dashboard maintainers. Here is an opened issue and a pending PR that's mentioned there: https://github.com/Parallels/rq-dashboard/issues/362

Related