##// END OF EJS Templates
util: simplify pipefilter and avoid subprocess race...
Martin Geisler -
r8302:d2ad8c06 default
parent child Browse files
Show More
@@ -122,23 +122,10 b' class propertycache(object):'
122
122
123 def pipefilter(s, cmd):
123 def pipefilter(s, cmd):
124 '''filter string S through command CMD, returning its output'''
124 '''filter string S through command CMD, returning its output'''
125 (pin, pout) = popen2(cmd, 'b')
125 p = subprocess.Popen(cmd, shell=True, close_fds=closefds,
126 def writer():
126 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
127 try:
127 pout, perr = p.communicate(s)
128 pin.write(s)
128 return pout
129 pin.close()
130 except IOError, inst:
131 if inst.errno != errno.EPIPE:
132 raise
133
134 # we should use select instead on UNIX, but this will work on most
135 # systems, including Windows
136 w = threading.Thread(target=writer)
137 w.start()
138 f = pout.read()
139 pout.close()
140 w.join()
141 return f
142
129
143 def tempfilter(s, cmd):
130 def tempfilter(s, cmd):
144 '''filter string S through a pair of temporary files with CMD.
131 '''filter string S through a pair of temporary files with CMD.
General Comments 0
You need to be logged in to leave comments. Login now