下列代码中,func 函数无法被 pool.apply_async 调用,这是什么情况?
import time
from multiprocessing.pool import Pool
class Test:
def __init__(self):
self.pool = Pool(5)
def func(self):
time.sleep(0.2)
print("1")
def run(self):
for i in range(10):
self.pool.apply_async(self.func) # 这里的 func 为什么不能进入执行?
time.sleep(3)
self.pool.close()
self.pool.join()
if __name__ == '__main__':
t = Test()
t.run()