我知道关于池的多处理的基本用法,我使用apply_async()func来避免阻塞,我的问题代码如下:
from multiprocessing import Pool, Queue
import time
q = Queue(maxsize=20)
script = "my_path/my_exec_file"
def initQueue():
...
def test_func(queue):
print 'Coming'
While True:
do_sth
...
if __name__ == '__main__':
initQueue()
pool = Pool(processes=3)
for i in xrange(11,20):
result = pool.apply_async(test_func, (q,))
pool.close()
while True:
if q.empty():
print 'Queue is emty,quit'
break
print 'Main Process Lintening'
time.sleep(2)
输出的结果总是主要的过程,我可以;我找不到“来”这个词。。 上面的代码没有语法错误,也没有任何异常。 任何人都可以帮忙,谢谢
目前没有回答
相关问题 更多 >
编程相关推荐