process.wait blocks GIL on Windows
jmthomas opened this issue · comments
It appears like this was "fixed" by issue #68 but I'm still seeing the same thing. Here is my example program on Windows 7, Ruby 2.2.4, childprocess 0.5.9:
require 'childprocess'
def run_process(command)
r, w = IO.pipe
process = ChildProcess.build("cmd.exe", "/c", command)
process.io.stdout = process.io.stderr = w
process.start
#process.wait # This blocks the second thread from running
sleep 0.1 while process.alive? # This logic works
w.close # Close the IO pipe
# Return output, status just like Open3
return [r.read, process.exit_code]
end
threads = []
threads << Thread.new { o,s = run_process("ping 123.123.123.123"); puts "1:#{Time.now} s:#{s} o:#{o}" }
threads << Thread.new { o,s = run_process("dir"); puts "2:#{Time.now} s:#{s} o:#{o}" }
threads.each {|t| t.join }
Closing due to staleness. If this is still an issue on a recent version of ChildProcess (e.g. 0.9.0), please feel free to reopen!