[Tutor] Consequences of opening subprocesses?
ctsterne at gmail.com
Fri Nov 26 21:16:58 CET 2010
I'm practicing python by rewriting some bash scripts, and I've found a few
things that I can't directly translate, like certain calls to command-line
tools. I've figured out how to start them with the subprocess module, but
I'm wondering if I'm going to get myself in hot water memory- or
performance-wise since these scripts are scheduled to run on thousands of
files fairly often. Do I need to explicitly close the subprocesses, or clean
them up, or something (I have some programming experience, but not a lot of
experience with taking into account these kinds of issues - ie, no C ... )?
An example is a call to the command-line image manipulation program,
s = subprocess.Popen(['identify', '-format', ''%w %h\n'', 'testimg.jpg'],
output = s.communicate()
# output should be the dimensions of testimg.jpg in pixels, ie, 100 50
What I'm thinking is that if, when typed into the terminal, the command
appears to give me some output and then exit like the one above (or bash
commands like "ls -l"), then I'm ok ... but like I said, I just don't know
much about this kind of issue. Can anyone tell me if my intuition's way off
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor