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)
| 195 | |
| 196 | @support.requires_subprocess() |
| 197 | def 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 | |
| 220 | def kill_python(p): |
searching dependent graphs…