MCPcopy Create free account
hub / github.com/ipython/ipython / _system_body

Function _system_body

IPython/utils/_process_win32.py:95–120  ·  view source on GitHub ↗

Callback for _system.

(p)

Source from the content-addressed store, hash-verified

93
94
95def _system_body(p):
96 """Callback for _system."""
97 enc = DEFAULT_ENCODING
98
99 def stdout_read():
100 for line in read_no_interrupt(p.stdout).splitlines():
101 line = line.decode(enc, 'replace')
102 print(line, file=sys.stdout)
103
104 def stderr_read():
105 for line in read_no_interrupt(p.stderr).splitlines():
106 line = line.decode(enc, 'replace')
107 print(line, file=sys.stderr)
108
109 Thread(target=stdout_read).start()
110 Thread(target=stderr_read).start()
111
112 # Wait to finish for returncode. Unfortunately, Python has a bug where
113 # wait() isn't interruptible (https://bugs.python.org/issue28168) so poll in
114 # a loop instead of just doing `return p.wait()`.
115 while True:
116 result = p.poll()
117 if result is None:
118 time.sleep(0.01)
119 else:
120 return result
121
122
123def system(cmd):

Callers

nothing calls this directly

Calls 1

startMethod · 0.45

Tested by

no test coverage detected