比如现有需求伪代码如下
pool = new Pool()
rp = Manager.list()
def func(key):
# 设置为正在执行
rp.append(key)
while True:
item = redis.lpop(key)
if not item:
break
......
# 处理完了移出
rp.remove(key)
while True:
# 如果redis里有新的p:*出现
for key in redis.scan('p:*'):
# 并且当前并没有在执行中
if key not in rp:
pool.apply_async(func, (key,))
pool.close()
pool.join()
实际效果 func 一直没执行 =。=