classification
Title: Improve subprocess module usage
Type: resource usage Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: dwblas, georg.brandl, loewis, mmokrejs
Priority: normal Keywords:

Created on 2008-06-29 09:26 by mmokrejs, last changed 2008-07-05 16:39 by georg.brandl. This issue is now closed.

Messages (7)
msg68943 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2008-06-29 09:26
Although I do appreciate that you try to improve python it is not clear
to me from http://docs.python.org/lib/module-subprocess.html:

1. Why the old functions have been deprecated
2. I can pipe together two processes. But how can I use pipe to feed the
first process of the two? The example at
http://docs.python.org/lib/node535.html is not sufficient. Show how to
bind together cat(1) and tr(1). Cat should read from STDIN and pass the
same to STDOUT, being read by tr(1).
3. Nowhere is explained what this magic really does:
   output = p2.communicate()[0]
   I figured out the result is e.g. a string of '\n' separated lines.
   What is not clear whether at this very moment the processes get
   started and whether one can still write on input to them. It seems
   not, the p1.stdin has to be already populated with data.
Thanks.
msg68944 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2008-06-29 10:10
Please link to http://www.python.org/dev/peps/pep-0324/ from the docs
webpage at least.
msg68956 - (view) Author: David (dwblas) Date: 2008-06-29 17:16
See if Doug Hellman's module of the week helps any
http://blog.doughellmann.com/2007/07/pymotw-subprocess.html  I plan on
asking him if we can include some of his examples in the Python 3000
docs.  Subprocess is new enough and gets enough questions on the forums
that I think we should be as detailed as possible and include more
examples than there are in other doc/tools examples.
msg68959 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-06-29 17:29
1. The documentation never gives a rationale for deprecating things. To
find out why they are deprecated, you'll typically have to research what
checkins to a code base have been made that added the deprecation, and
perhaps also ask on mailing lists. For the regular developer, the
rationale for deprecation should be irrelevant, as he needs to change
his code to drop usage of the deprecated API, anyway.

2. You really need to read all of the documentation, in particular the
section that talks about stdin,stdout,stderr in

http://docs.python.org/lib/node528.html

In the example, stdin is inherited from the parent process. Read the
documentation to find out how to send data to the first process.

3. It is not true that this is nowhere explained.

http://docs.python.org/lib/node532.html

explains precisely what the semantics of communicate is.
msg69062 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-01 20:00
Added a link to PEP 324 in r64625. The other issues were explained by
Martin; it will be easier to read the subprocess docs in 2.6 where
they're all on one page.
msg69111 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2008-07-02 19:39
Georg, but would you please improve the docs explaining what communicate
really does? The syntax is nice but I don't see how can I use poll()
described in the same above to use that. Providing Examples section
would be the best. Of course I don't mind if the examples come from Doug
Hellman or not, as mentioned in msg68956. ;-) Or how about placing a
link to that page
(http://blog.doughellmann.com/2007/07/pymotw-subprocess.html)?

Please reopen unless better docs are available. I don't care about 2.6
either, sorry.
msg69284 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-05 16:39
I don't understand the comment about poll().

In any case, I plan on referencing Doug's PyMOTW pages for all modules
he does, since they are indeed excellent tutorials.
History
Date User Action Args
2008-07-05 16:39:38georg.brandlsetmessages: + msg69284
2008-07-02 19:39:21mmokrejssetmessages: + msg69111
2008-07-01 20:00:22georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg69062
2008-06-29 17:29:08loewissetnosy: + loewis
messages: + msg68959
2008-06-29 17:16:10dwblassetnosy: + dwblas
messages: + msg68956
2008-06-29 10:10:05mmokrejssetmessages: + msg68944
2008-06-29 09:26:13mmokrejscreate