This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author GranPrego
Recipients GranPrego, paul.moore, steve.dower, tim.golden, zach.ware
Date 2018-05-22.14:59:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527001161.43.0.682650639539.issue33603@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-05-22 14:59:21GranPregosetrecipients: + GranPrego, paul.moore, tim.golden, zach.ware, steve.dower
2018-05-22 14:59:21GranPregosetmessageid: <1527001161.43.0.682650639539.issue33603@psf.upfronthosting.co.za>
2018-05-22 14:59:21GranPregolinkissue33603 messages
2018-05-22 14:59:21GranPregocreate