我是python多线程编程的新手,目前我想创建一个worker并打印消息,我使用以下代码:
def worker_main(msg):
print 'success'
print "{0} retrieved: {1}".format(getpid(), msg)
sleep(1)
if __name__ == '__main__':
pool = Pool(5)
for i in range(50):
print i
pool.apply_async(worker_main, ("First item for loop %d" % i))
目前,它仅显示i,但不运行worker_main,有人知道为什么吗? 谢谢