1

Redis version=6.0.9( Ubuntu 18.04 マシンに) redis をインストールして実行しており、この簡単なガイドに従ってジョブをスケジュールしましたが、 redis ワーカーrqを起動するとすぐに次のエラーが表示されます。app.py

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

2 番目のウィンドウを開いて実行するrq workerと、この投稿の最初の部分で失敗しました。

私はググってみましたが、この投稿は彼が彼のWindows OSを更新したとだけ言っていました.

4

0 に答える 0