值错误:时间数据与格式"%Y-%m-%dT%H:%M:%SZ"格式不匹配



我试图在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'))

我正在排队从另一个文件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中排队,但是它没有一个worker来运行东西,我只想在ubuntu中运行一个worker。redis-server是本地托管的。我检查了任务是否正确排队,但它显示它们是0个工人。我不知道还能写些什么,但关于这一点,请随时提问。

在您提供的错误中,没有时间戳(")被发送到rq:

ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

检查是否安装了一个名为python-rq的冲突包:

https://github.com/rq/rq/issues/1309

如果没有,检查你的语言环境是否在Ubuntu中设置正确,然后使用'date'命令产生预期的结果。接下来检查Python是否也返回正确的日期:

import datetime;
print(datetime.datetime.now())

相关内容

  • 没有找到相关文章

最新更新