MCPcopy Index your code
hub / github.com/RustPython/RustPython / spawn_python

Function spawn_python

Lib/test/support/script_helper.py:196–216  ·  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

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

Calls 4

appendMethod · 0.45
extendMethod · 0.45
setdefaultMethod · 0.45