我正在使用带有烧瓶的RQ在循环中排队作业。我有以下代码:
from rq import Queue
from rq.job import Job
from worker import conn
q = Queue(connection=conn)
for i in range(5):
job = q.enqueue_call(
func=process_data, args=(i, data,))
print(job.get_id())
现在我得到错误:
TypeError: cannot pickle '_thread.lock' object
我有以下代码的工人:
import os
import redis
from rq import Worker, Queue, Connection
listen = ['default']
redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')
conn = redis.from_url(redis_url)
if __name__ == '__main__':
with Connection(conn):
worker = Worker(list(map(Queue, listen)))
worker.work()
如何纠正这种情况?
呼唤远方
阿波罗的战车
相关分类