Pool.map
用於計分程序
:的Python multiprocessing.Pool&存儲器
- 從數據源「光標」具有數百萬陣列
- 計算
- 結果保存在數據宿
結果是獨立的。
我只是想知道是否可以避免內存需求。起初 似乎每個數組都進入python,然後2和3是 繼續。無論如何,我有一個速度提高。
#data src and sink is in mongodb#
def scoring(some_arguments):
### some stuff and finally persist ###
collection.update({uid:_uid},{'$set':res_profile},upsert=True)
cursor = tracking.find(timeout=False)
score_proc_pool = Pool(options.cores)
#finaly I use a wrapper so I have only the document as input for map
score_proc_pool.map(scoring_wrapper,cursor,chunksize=10000)
我做錯了什麼或者是否有更好的方法與python爲此目的?
任何代碼片段一起幫助我們? – usethedeathstar