import time,os from multiprocessing import Manager,Pool
def test_try(multiprocess_queue):
print(os.getpid())
check_multiprocess_queue = multiprocess_queue.empty()
if check_multiprocess_queue:
print('队列为空')
else:
each_data = multiprocess_queue.get()
print(os.getpid())
if name == 'main':
while True:
multiprocess_queue = Manager().Queue()
multiprocess_queue.put('a')
pool = Pool(processes=2) # 最大核数
for d in range(2):
pool.apply_async(func=test_try, args=(multiprocess_queue,))
pool.close()
pool.join()
1
AlohaV2 2020-08-21 22:27:21 +08:00 via iPhone
没有对齐对于 python 代码来说是很致命的,比如我不知道 while True 的作用范围是什么
|
2
dingwen07 2020-08-21 22:47:57 +08:00 via iPhone
你这没缩进让人怎么看
|
3
lzp729 2020-08-21 22:52:32 +08:00
linux 默认是 fork
|