MCPcopy Index your code
hub / github.com/python/cpython / Process

Class Process

Lib/asyncio/subprocess.py:118–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116
117
118class Process:
119 def __init__(self, transport, protocol, loop):
120 self._transport = transport
121 self._protocol = protocol
122 self._loop = loop
123 self.stdin = protocol.stdin
124 self.stdout = protocol.stdout
125 self.stderr = protocol.stderr
126 self.pid = transport.get_pid()
127
128 def __repr__(self):
129 return f'<{self.__class__.__name__} {self.pid}>'
130
131 @property
132 def returncode(self):
133 return self._transport.get_returncode()
134
135 async def wait(self):
136 """Wait until the process exit and return the process return code."""
137 return await self._transport._wait()
138
139 def send_signal(self, signal):
140 self._transport.send_signal(signal)
141
142 def terminate(self):
143 self._transport.terminate()
144
145 def kill(self):
146 self._transport.kill()
147
148 async def _feed_stdin(self, input):
149 debug = self._loop.get_debug()
150 try:
151 if input is not None:
152 self.stdin.write(input)
153 if debug:
154 logger.debug(
155 '%r communicate: feed stdin (%s bytes)', self, len(input))
156
157 await self.stdin.drain()
158 except (BrokenPipeError, ConnectionResetError) as exc:
159 # communicate() ignores BrokenPipeError and ConnectionResetError.
160 # write() and drain() can raise these exceptions.
161 if debug:
162 logger.debug('%r communicate: stdin got %r', self, exc)
163
164 if debug:
165 logger.debug('%r communicate: close stdin', self)
166 self.stdin.close()
167
168 async def _noop(self):
169 return None
170
171 async def _read_stream(self, fd):
172 transport = self._transport.get_pipe_transport(fd)
173 if fd == 2:
174 stream = self.stderr
175 else:

Callers 2

create_subprocess_shellFunction · 0.70
create_subprocess_execFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…