[issue27448] Race condition in subprocess.Popen which causes a huge memory leak

Andrew report at bugs.python.org
Mon Jul 4 15:43:23 EDT 2016


Andrew added the comment:

pppery, I don't think I am breaking gc functionality with my code. The code line I gave just meant to give the basic idea of what was helping to workaround this. If you are actually interested in the code I use, it is below:

def fix_subprocess_racecondition():
  """
  !!! PLEASE NOTE THIS SHOULD BE CALLED BEFORE ANY OTHER INITIALIZATION was done to avoid already created links to subprocess or subprocess.gc or gc
  """
  # monkey patching subprocess
  import subprocess
  subprocess.gc.isenabled = lambda: True

  # re-importing gc to have correct isenabled for non-subprocess contexts
  import sys
  del sys.modules['gc']
  import gc

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27448>
_______________________________________


More information about the Python-bugs-list mailing list