我试图在ubuntu中运行rq worker,但是当我输入
rq worker
它给了我这个错误
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'))
我正在从另一个文件www.example.com排队一个简单的任务hello.py,代码:
def add(x, y):
return x + y
这是我的main.py代码
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)
它在redis-server中排队,但是它没有一个工作者来运行,我只想要一个在ubuntu中运行的工作者。而且redis-server是本地托管的。我检查了任务是否正确排队,但是显示它们是0个工作者。我不知道还能写什么,但是可以随时问关于这个的任何问题。
1条答案
按热度按时间doinxwow1#
在您提供的错误中,没有发送到rq的时间戳(''):
根据此问题检查您是否安装了名为python-rq的冲突包:
https://github.com/rq/rq/issues/1309
如果没有,检查你的语言环境在Ubuntu中是否设置正确,'date'命令是否产生了预期的结果,接下来检查Python是否也返回了正确的日期: