Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="node240.html" /> | |
13 | <link rel="prev" href="node235.html" /> | |
14 | <link rel="parent" href="module-subprocess.html" /> | |
15 | <link rel="next" href="node240.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>6.8.2 Popen Objects</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="6.8.1.3 Security" | |
25 | href="node238.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="6.8 subprocess " | |
28 | href="module-subprocess.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="6.8.3 Replacing Older Functions" | |
31 | href="node240.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="node238.html">6.8.1.3 Security</A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="module-subprocess.html">6.8 subprocess </A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="node240.html">6.8.3 Replacing Older Functions</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H2><A NAME="SECTION008820000000000000000"> | |
56 | 6.8.2 Popen Objects</A> | |
57 | </H2> | |
58 | ||
59 | <P> | |
60 | Instances of the <tt class="class">Popen</tt> class have the following methods: | |
61 | ||
62 | <P> | |
63 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
64 | <td><nobr><b><tt id='l2h-1835' xml:id='l2h-1835' class="method">poll</tt></b>(</nobr></td> | |
65 | <td><var></var>)</td></tr></table></dt> | |
66 | <dd> | |
67 | Check if child process has terminated. Returns returncode | |
68 | attribute. | |
69 | </dl> | |
70 | ||
71 | <P> | |
72 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
73 | <td><nobr><b><tt id='l2h-1836' xml:id='l2h-1836' class="method">wait</tt></b>(</nobr></td> | |
74 | <td><var></var>)</td></tr></table></dt> | |
75 | <dd> | |
76 | Wait for child process to terminate. Returns returncode attribute. | |
77 | </dl> | |
78 | ||
79 | <P> | |
80 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
81 | <td><nobr><b><tt id='l2h-1837' xml:id='l2h-1837' class="method">communicate</tt></b>(</nobr></td> | |
82 | <td><var>input=None</var>)</td></tr></table></dt> | |
83 | <dd> | |
84 | Interact with process: Send data to stdin. Read data from stdout and | |
85 | stderr, until end-of-file is reached. Wait for process to terminate. | |
86 | The optional <var>input</var> argument should be a string to be sent to the | |
87 | child process, or <code>None</code>, if no data should be sent to the child. | |
88 | ||
89 | <P> | |
90 | communicate() returns a tuple (stdout, stderr). | |
91 | ||
92 | <P> | |
93 | <span class="note"><b class="label">Note:</b> | |
94 | The data read is buffered in memory, so do not use this method | |
95 | if the data size is large or unlimited.</span> | |
96 | </dl> | |
97 | ||
98 | <P> | |
99 | The following attributes are also available: | |
100 | ||
101 | <P> | |
102 | <dl><dt><b><tt id='l2h-1838' xml:id='l2h-1838' class="member">stdin</tt></b></dt> | |
103 | <dd> | |
104 | If the <var>stdin</var> argument is <code>PIPE</code>, this attribute is a file | |
105 | object that provides input to the child process. Otherwise, it is | |
106 | <code>None</code>. | |
107 | </dl> | |
108 | ||
109 | <P> | |
110 | <dl><dt><b><tt id='l2h-1839' xml:id='l2h-1839' class="member">stdout</tt></b></dt> | |
111 | <dd> | |
112 | If the <var>stdout</var> argument is <code>PIPE</code>, this attribute is a file | |
113 | object that provides output from the child process. Otherwise, it is | |
114 | <code>None</code>. | |
115 | </dl> | |
116 | ||
117 | <P> | |
118 | <dl><dt><b><tt id='l2h-1840' xml:id='l2h-1840' class="member">stderr</tt></b></dt> | |
119 | <dd> | |
120 | If the <var>stderr</var> argument is <code>PIPE</code>, this attribute is file | |
121 | object that provides error output from the child process. Otherwise, | |
122 | it is <code>None</code>. | |
123 | </dl> | |
124 | ||
125 | <P> | |
126 | <dl><dt><b><tt id='l2h-1841' xml:id='l2h-1841' class="member">pid</tt></b></dt> | |
127 | <dd> | |
128 | The process ID of the child process. | |
129 | </dl> | |
130 | ||
131 | <P> | |
132 | <dl><dt><b><tt id='l2h-1842' xml:id='l2h-1842' class="member">returncode</tt></b></dt> | |
133 | <dd> | |
134 | The child return code. A <code>None</code> value indicates that the process | |
135 | hasn't terminated yet. A negative value -N indicates that the child | |
136 | was terminated by signal N (<span class="Unix">Unix</span> only). | |
137 | </dl> | |
138 | ||
139 | <P> | |
140 | ||
141 | <DIV CLASS="navigation"> | |
142 | <div class='online-navigation'> | |
143 | <p></p><hr /> | |
144 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
145 | <tr> | |
146 | <td class='online-navigation'><a rel="prev" title="6.8.1.3 Security" | |
147 | href="node238.html"><img src='../icons/previous.png' | |
148 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
149 | <td class='online-navigation'><a rel="parent" title="6.8 subprocess " | |
150 | href="module-subprocess.html"><img src='../icons/up.png' | |
151 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
152 | <td class='online-navigation'><a rel="next" title="6.8.3 Replacing Older Functions" | |
153 | href="node240.html"><img src='../icons/next.png' | |
154 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
155 | <td align="center" width="100%">Python Library Reference</td> | |
156 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
157 | href="contents.html"><img src='../icons/contents.png' | |
158 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
159 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
160 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
161 | <td class='online-navigation'><a rel="index" title="Index" | |
162 | href="genindex.html"><img src='../icons/index.png' | |
163 | border='0' height='32' alt='Index' width='32' /></A></td> | |
164 | </tr></table> | |
165 | <div class='online-navigation'> | |
166 | <b class="navlabel">Previous:</b> | |
167 | <a class="sectref" rel="prev" href="node238.html">6.8.1.3 Security</A> | |
168 | <b class="navlabel">Up:</b> | |
169 | <a class="sectref" rel="parent" href="module-subprocess.html">6.8 subprocess </A> | |
170 | <b class="navlabel">Next:</b> | |
171 | <a class="sectref" rel="next" href="node240.html">6.8.3 Replacing Older Functions</A> | |
172 | </div> | |
173 | </div> | |
174 | <hr /> | |
175 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
176 | </DIV> | |
177 | <!--End of Navigation Panel--> | |
178 | <ADDRESS> | |
179 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
180 | </ADDRESS> | |
181 | </BODY> | |
182 | </HTML> |