Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve subprocess module usage #47485

Closed
mmokrejs mannequin opened this issue Jun 29, 2008 · 7 comments
Closed

Improve subprocess module usage #47485

mmokrejs mannequin opened this issue Jun 29, 2008 · 7 comments
Assignees
Labels
docs Documentation in the Doc dir performance Performance or resource usage

Comments

@mmokrejs
Copy link
Mannequin

mmokrejs mannequin commented Jun 29, 2008

BPO 3235
Nosy @loewis, @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/birkenfeld'
closed_at = <Date 2008-07-01.20:00:22.246>
created_at = <Date 2008-06-29.09:26:13.726>
labels = ['docs', 'performance']
title = 'Improve subprocess module usage'
updated_at = <Date 2008-07-05.16:39:38.860>
user = 'https://bugs.python.org/mmokrejs'

bugs.python.org fields:

activity = <Date 2008-07-05.16:39:38.860>
actor = 'georg.brandl'
assignee = 'georg.brandl'
closed = True
closed_date = <Date 2008-07-01.20:00:22.246>
closer = 'georg.brandl'
components = ['Documentation']
creation = <Date 2008-06-29.09:26:13.726>
creator = 'mmokrejs'
dependencies = []
files = []
hgrepos = []
issue_num = 3235
keywords = []
message_count = 7.0
messages = ['68943', '68944', '68956', '68959', '69062', '69111', '69284']
nosy_count = 4.0
nosy_names = ['loewis', 'georg.brandl', 'mmokrejs', 'dwblas']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'resource usage'
url = 'https://bugs.python.org/issue3235'
versions = ['Python 2.5']

@mmokrejs
Copy link
Mannequin Author

mmokrejs mannequin commented Jun 29, 2008

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.

@mmokrejs mmokrejs mannequin assigned birkenfeld Jun 29, 2008
@mmokrejs mmokrejs mannequin added docs Documentation in the Doc dir performance Performance or resource usage labels Jun 29, 2008
@mmokrejs
Copy link
Mannequin Author

mmokrejs mannequin commented Jun 29, 2008

Please link to http://www.python.org/dev/peps/pep-0324/ from the docs
webpage at least.

@dwblas
Copy link
Mannequin

dwblas mannequin commented Jun 29, 2008

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.

@loewis
Copy link
Mannequin

loewis mannequin commented Jun 29, 2008

  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.

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

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

explains precisely what the semantics of communicate is.

@birkenfeld
Copy link
Member

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.

@mmokrejs
Copy link
Mannequin Author

mmokrejs mannequin commented Jul 2, 2008

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.

@birkenfeld
Copy link
Member

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

1 participant