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

Function spawn_python

Lib/test/support/script_helper.py:197–217  ·  view source on GitHub ↗

Run a Python subprocess with the given arguments. kw is extra keyword args to pass to subprocess.Popen. Returns a Popen object.

(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw)

Source from the content-addressed store, hash-verified

195
196@support.requires_subprocess()
197def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
198 """Run a Python subprocess with the given arguments.
199
200 kw is extra keyword args to pass to subprocess.Popen. Returns a Popen
201 object.
202 """
203 cmd_line = [sys.executable]
204 if not interpreter_requires_environment():
205 cmd_line.append('-E')
206 cmd_line.extend(args)
207 # Under Fedora (?), GNU readline can output junk on stderr when initialized,
208 # depending on the TERM setting. Setting TERM=vt100 is supposed to disable
209 # that. References:
210 # - http://reinout.vanrees.org/weblog/2009/08/14/readline-invisible-character-hack.html
211 # - http://stackoverflow.com/questions/15760712/python-readline-module-prints-escape-character-during-import
212 # - http://lists.gnu.org/archive/html/bug-readline/2007-08/msg00004.html
213 env = kw.setdefault('env', dict(os.environ))
214 env['TERM'] = 'vt100'
215 return subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
216 stdout=stdout, stderr=stderr,
217 **kw)
218
219
220def kill_python(p):

Calls 4

appendMethod · 0.45
extendMethod · 0.45
setdefaultMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…