##// END OF EJS Templates
Attempt to make Popen.wait() interruptible.
Itamar Turner-Trauring -
Show More
@@ -21,7 +21,7 b' import ctypes'
21 21
22 22 from ctypes import c_int, POINTER
23 23 from ctypes.wintypes import LPCWSTR, HLOCAL
24 from subprocess import STDOUT
24 from subprocess import STDOUT, TimeoutExpired
25 25
26 26 # our own imports
27 27 from ._process_common import read_no_interrupt, process_handler, arg_split as py_arg_split
@@ -100,8 +100,14 b' def _system_body(p):'
100 100 line = line.decode(enc, 'replace')
101 101 print(line, file=sys.stderr)
102 102
103 # Wait to finish for returncode
104 return p.wait()
103 # Wait to finish for returncode. Unfortunately, Python has a bug where
104 # wait() isn't interruptible (https://bugs.python.org/issue28168) so poll in
105 # a loop instead of just doing `return p.wait()`.
106 while True:
107 try:
108 return p.wait(0.01)
109 except TimeoutExpired:
110 pass
105 111
106 112
107 113 def system(cmd):
General Comments 0
You need to be logged in to leave comments. Login now