跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 请教 multiprocessing 问题,在 window7 下运行可以正常打印, ubuntu 运行一会就卡死了。
未分類
3 9 月 2020

请教 multiprocessing 问题,在 window7 下运行可以正常打印, ubuntu 运行一会就卡死了。

请教 multiprocessing 问题,在 window7 下运行可以正常打印, ubuntu 运行一会就卡死了。

資深大佬 : naldo0193 12

在 window7 下运行可以正常打印,ubuntu 运行一会就卡死了。

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()

大佬有話說 (3)

  • 資深大佬 : AlohaV2

    没有对齐对于 python 代码来说是很致命的,比如我不知道 while True 的作用范围是什么

  • 資深大佬 : dingwen07

    你这没缩进让人怎么看

  • 資深大佬 : lzp729

    linux 默认是 fork

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具