I am trying to run rq worker in ubuntu but when I type
rq worker
It gives me this error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/rq/utils.py", line 169, in utcparse
return datetime.datetime.strptime(string, _TIMESTAMP_FORMAT)
File "/usr/lib/python3.8/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/rq/worker.py", line 508, in work
result = self.dequeue_job_and_maintain_ttl(timeout)
File "/usr/lib/python3/dist-packages/rq/worker.py", line 574, in dequeue_job_and_maintain_ttl
result = self.queue_class.dequeue_any(self.queues, timeout,
File "/usr/lib/python3/dist-packages/rq/queue.py", line 539, in dequeue_any
job = job_class.fetch(job_id, connection=connection)
File "/usr/lib/python3/dist-packages/rq/job.py", line 303, in fetch
job.refresh()
File "/usr/lib/python3/dist-packages/rq/job.py", line 515, in refresh
self.restore(data)
File "/usr/lib/python3/dist-packages/rq/job.py", line 478, in restore
self.started_at = str_to_date(obj.get('started_at'))
I am queueing a simple task from another file hello.py, the code:
def add(x, y):
return x + y
and this is my main.py code:
from flask import Flask
from redis import Redis
from hello import add
from rq import Queue
q = Queue(connection=Redis())
app = Flask(__name__)
@app.route("/")
def hello():
q.enqueue(add, 3, 7)
return "Task enqueued"
if __name__ == "__main__":
app.run(debug=True)
It is queueing the things in redis-server but it doesn't have a worker to run things, I just want a worker running in ubuntu. And the redis-server is hosted locally. I checked even the task is enqueueing properly but it is showing that their are 0 workers. I don't know what else to write but feel free to ask anything regarding this.
In the error you provided, there is no timestamp ('') being sent to rq :
ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
Check to see if you have a conflicting package called python-rq installed per this issue :
https://github.com/rq/rq/issues/1309
If not, check that your locale is set correctly in Ubuntu and the 'date' command produce the expected result. Next check that the Python also returns the correct date :
import datetime;
print(datetime.datetime.now())