redis python3 rq worker在缺勤日期对utcparse start\u失败

jobtbby3  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(226)

我已经安装并运行了redis( Redis version=6.0.9 在ubuntu18.04机器上),并遵循此简单指南使用 rq 但我一发射 app.py redis worker失败:

10:31:17 RQ worker u'rq:worker:c73feeafc20f4f0c8baff1e5225e73f1' started, version 1.0
10:31:17***Listening on default...
10:31:18 Worker c73feeafc20f4f0c8baff1e5225e73f1: found an unhandled exception, quitting...
Traceback (most recent call last):
  File "/home/enrico/.local/lib/python2.7/site-packages/rq/worker.py", line 470, in work
    result = self.dequeue_job_and_maintain_ttl(timeout)
  File "/home/enrico/.local/lib/python2.7/site-packages/rq/worker.py", line 514, in dequeue_job_and_maintain_ttl
    job_class=self.job_class)
  File "/home/enrico/.local/lib/python2.7/site-packages/rq/queue.py", line 468, in dequeue_any
    job = job_class.fetch(job_id, connection=connection)
  File "/home/enrico/.local/lib/python2.7/site-packages/rq/job.py", line 287, in fetch
    job.refresh()
  File "/home/enrico/.local/lib/python2.7/site-packages/rq/job.py", line 428, in refresh
    self.started_at = to_date(as_text(obj.get('started_at')))
  File "/home/enrico/.local/lib/python2.7/site-packages/rq/job.py", line 411, in to_date
    return utcparse(as_text(date_str))
  File "/home/enrico/.local/lib/python2.7/site-packages/rq/utils.py", line 175, in utcparse
    return datetime.datetime.strptime(string, '%Y-%m-%dT%H:%M:%SZ')
  File "/usr/lib/python2.7/_strptime.py", line 332, in _strptime
    (data_string, format))
ValueError: time data '' does not match format '%Y-%m-%dT%H:%M:%SZ'

在这里 tasks.py :

from datetime import datetime, timedelta
import time

def print_task(seconds):
    print("Starting task")
    for num in range(seconds):
        print(num, ". Hello World!")
        time.sleep(1)
    print("Task completed")

def print_numbers(seconds):
    print("Starting num task")
    for num in range(seconds):
        print(num)
        time.sleep(1)
    print("Task to print_numbers completed")

在这里 app.py :

from datetime import datetime, timedelta
import time
from redis import Redis
from rq import Queue
import tasks

queue = Queue(connection=Redis())

def queue_tasks():
    queue.enqueue(tasks.print_task, 5)
    queue.enqueue_in(timedelta(seconds=10), tasks.print_numbers, 5)

def main():
    queue_tasks()

if __name__ == "__main__":
    main()

这里是我使用的命令:

python3.8 -m venv venv
source venv/bin/activate
pip install rq   ### Successfully installed click-7.1.2 redis-3.5.3 rq-1.7.0
python app.py

我打开第二扇Windows就跑 rq worker 我在这篇文章的第一部分就失败了。
我试着在谷歌上搜索,但这篇文章只是说,他更新了他的windows操作系统,这是一个已解决的错误…有人知道如何解决这个线索吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题