redis队列工作进程在utcparse中崩溃

pbgvytdp  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(421)

我试图得到一个基本的rq工作后,教程在https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xxii-background-jobs.
我运行的是windows10wsl1ubuntu20.04。
我使用 sudo apt-get install python3-rq rq的版本是1.2.2
我使用 pip3 install rq 现在是1.4.0版。
我的工作代码位于app/tasks.py中

import time

def example():
    print('Starting task')
    for i in range(1..10):
        print(i)
        #time.sleep(1)
    print('Task completed')

当我这么做的时候 $ rq worker testrq 这似乎是开始好,报告

Worker rq:worker:6080c3a42475423895995e6da528ad2e: started, version 1.2.2
 ***Listening on testrq...
   Cleaning registries for queue: testrq

在另一个终端上,我启动python3并发出以下命令:

>>> from redis import Redis
>>> import rq
>>> q = rq.Queue('testrq', connection=Redis.from_url('redis://'))
>>> job = q.enqueue('app.tasks.example')

当输入最后一条语句时,侦听过程报告以下内容,然后退出:

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'))
  File "/usr/lib/python3/dist-packages/rq/utils.py", line 256, in str_to_date
    return utcparse(as_text(date_str))
  File "/usr/lib/python3/dist-packages/rq/utils.py", line 172, in utcparse
    return datetime.datetime.strptime(string, '%Y-%m-%dT%H:%M:%SZ')
  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:%SZ'

谁能告诉我怎么修这个吗?谢谢
我在网上搜索时遇到的pshttps://github.com/rq/rq/issues/927; 不确定这是否相关。

twh00eeo

twh00eeo1#

万一有人有什么问题。。。
我设法升级了Windows10操作系统并启用了wsl2。然后任务正常运行,所以我只能假设这是wsl1中的某个bug。
当然,它立刻突出了我的语法错误 range(1..10) . 哦!鲁比也许走了,但显然没有忘记!

相关问题