Created
November 18, 2014 05:05
-
-
Save puriketu99/9798d12f07981d4c18b0 to your computer and use it in GitHub Desktop.
PythonのmultiprocessingでPool.close()してもプロセスが一時停止中のまま残ってメモリがどんどん増える問題 ref: http://qiita.com/puriketu99/items/0e1c1c1b34df3fec9cbe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
def score4abc(a,b): | |
score = a,b | |
return score | |
def wrapper_score4multi(args): | |
return score4abc(*args) | |
def main(a,foo): | |
for i in range(500): | |
pool = multiprocessing.Pool(32) | |
pool.map(wrapper_score4multi,[[a,b] for b in foo]#常に32個のプロセスがR状態となり、終了したプロセスはS状態のままとどまる | |
pool.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment