用 rq 管理任务队列,每个工作任务里是开了线程执行其它任务,为啥程序没执行完就停止不执行了呢?并且出现 job ok 提示,明明没执行完,我在开的线程里循环输出 0-1000,有的 job 能全部输出,有的输出等到 600 就结束了,这是咋回事?烦请各位大佬指教.
1
Latin 2021-01-05 16:51:38 +08:00
不贴代码 怎么看
|
2
taomujian OP scan_data = {
'target': target, } scan = Scan(mysqldb) q.enqueue(scan.async_exe, scan_data) def async_exe(self, kwargs): thread = threading.Thread(target = self.run, args=(kwargs,), daemon = True) thread.start() def run(self, kwargs): for i in range(1000): print(i) |
3
taomujian OP #!/usr/bin/env python3
from redis import Redis from multiprocessing import Pool from rq import Queue, Worker, Connection redis_conn = Redis(host = '127.0.0.1', password = '', port = 6379) def worker(listen): with Connection(redis_conn): worker = Worker(map(Queue, listen)) worker.work() if __name__ == "__main__": listen = ['high', 'default', 'low'] worker(listen) |