New submission from GranPrego <josephdel...@googlemail.com>: On windows 7 / 10 I'm using subprocess to launch a dos cmdline executable and returning the results, which is all working fine. However, each time I make a call, the Python handle count is gradually increasing, jumping up , back a few, then jumping up and so on.
All the handles are released when the script exits, but quite often python just hangs after a few hours. If I use process explorer to investigate I can see that python has an increasing number of Thread handles, even though I can see the process being called and cleanly exiting. Unfortunately I'm stuck with the dos executable and it's always a one shot of sending it a single command each time and the script calls it a lot. The executable is just taking a string cmdline and returning a couple of lines of text and then exiting. It only runs for a couple of seconds at most. I've tried two variants of calling the process, I was hoping that the with variant would clean up, but there is no difference. Each handle object that gets left behind has a single reference and a non paged quota of 1192, 0 paged. The script is long running and I've seen the handle count reach 46K. result = "" with Popen ([fcptool, parameters], stdout=PIPE, universal_newlines=True, bufsize=1) as process: for line in process.stdout: result = result + line return result or p = subprocess.run([fcptool, parameters], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True).stdout return p I can reproduce this on 3 different machines, 2 windows 7 and one windows 10, all Python 3.6. I can't see a way around this at the moment and as far as I can tell, I'm using the call to subprocess correctly. ---------- components: Interpreter Core, Windows messages: 317296 nosy: GranPrego, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Subprocess Thread handles grow with each call and aren't released until script ends type: resource usage versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33603> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com