T
Tony.Makhlouf
Relatively new to Ruby (3 weeks) and Tk (3 days):
I have a ruby script that controls a C++ application via a pipe. I have
a Tk interface on top of it:
require 'tk'
require 'thread'
#setup Tk interface here
Thread.new { Tk.mainloop}; #Tk thread.
pipe=IO.popen("myapp.exe", "r+")
pipe.puts "input text goes here..."
loop do
app_out=pipe.gets #FREEZES Tk interface if lengthy
if (app_out=~/result is/)
puts "app has generated #{app_out}"
end
end
The problem I am facing is that the call to pipe.gets freezes the Tk
interface while waiting for a response from myapp.exe
I would like to find a way to do a non-blocking call to pipe.gets .
One solution I thought of is to launch a second ruby script in a
different process, and have that one talk via a pipe to myapp.exe, and
then communicate with the main script via some other non-blocking
method. Is there an easy way to have 2 Ruby scripts talk to each other,
other than pipes?
PS: must work on Win32 Active State or Cygwin
Thanks
I have a ruby script that controls a C++ application via a pipe. I have
a Tk interface on top of it:
require 'tk'
require 'thread'
#setup Tk interface here
Thread.new { Tk.mainloop}; #Tk thread.
pipe=IO.popen("myapp.exe", "r+")
pipe.puts "input text goes here..."
loop do
app_out=pipe.gets #FREEZES Tk interface if lengthy
if (app_out=~/result is/)
puts "app has generated #{app_out}"
end
end
The problem I am facing is that the call to pipe.gets freezes the Tk
interface while waiting for a response from myapp.exe
I would like to find a way to do a non-blocking call to pipe.gets .
One solution I thought of is to launch a second ruby script in a
different process, and have that one talk via a pipe to myapp.exe, and
then communicate with the main script via some other non-blocking
method. Is there an easy way to have 2 Ruby scripts talk to each other,
other than pipes?
PS: must work on Win32 Active State or Cygwin
Thanks