作者redbxh (林佳)
看板Python
标题[问题]multiprocessing
时间Fri Apr 4 00:17:59 2014
目前需要使用到 multiprocessing
我要做到的是 开启多个process 分别将资料进行 排序
排序法
def xxxxxSort( data_list ):
#略
return sorted
目前找到的资料是用 multiprocessing.Pool
我可以用 multiprocessing.Pool 来达到
多process 执行 function ( print something)
但是我一直无法取到我 执行完 xxxxxSort 之後回传的list
不过我有得到一些东西
像是 <multiprocessing.pool.ApplyResult object at 0x02716310>
请问有办法使用 multiprocessing 来达到 多process 排序&回传吗
还是要透过 object at 0x02716310 来取得 list?
请求各路高手解答
--
◢/ ◢/ ◢/
◢/◢◤ ███◣ ◢/█/ █/// ◢/◢/ █///
█◢◤ ████
███/ ███/ █◤█◤ ███/
█/ ██▆▆
█/█/ █/█/ ◢█◢/ █/█/
█◤ ◥█▆▆
███◤ ███◤ █◤█◤ █◤█◤ ψjimbox
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.166.145.1
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/Python/M.1396541882.A.49E.html
1F:→ LarryPage:p=multiprocessing.Pool(100) 04/04 00:49
2F:→ LarryPage:output_list = p.map(XXXXsort, input_list) 04/04 00:50
3F:→ LarryPage:print output_list 04/04 00:51
4F:→ LarryPage:[[1,4,5],[2,3],[7,9]] 04/04 00:51
5F:→ LarryPage:有错请指定 04/04 00:51
6F:推 tiefblau:call .get()才会是函式的回传值 话说楼上你有一百核吗? 04/04 01:02
7F:→ redbxh:1f 那样写是一百核还是允许最大100个process同时? 04/04 01:18
8F:→ redbxh:感谢1F 方法可行 3Q 04/04 03:18
9F:推 hsnu114444:100个process 04/25 22:55