Skip to content

Instantly share code, notes, and snippets.

@puriketu99
Created November 18, 2014 05:05
Show Gist options
  • Save puriketu99/9798d12f07981d4c18b0 to your computer and use it in GitHub Desktop.
Save puriketu99/9798d12f07981d4c18b0 to your computer and use it in GitHub Desktop.
PythonのmultiprocessingでPool.close()してもプロセスが一時停止中のまま残ってメモリがどんどん増える問題 ref: http://qiita.com/puriketu99/items/0e1c1c1b34df3fec9cbe
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