[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Weird thread behavior in windows.

Tim Uckun

3/14/2008 9:16:00 AM

Hello All.

I have some code that looks like this.

@tasks.run do |cmd|
@logger.info "Threading #{cmd} with timeout of #{@entries[cmd]}"
Thread.new(cmd) { |cmd|
Timeout::timeout(@entries[cmd]) do
begin
# Something that should be interrupted if it
takes too much time...
@logger.info( cmd + " Finished : " + eval(cmd).to_s)
rescue Timeout::Error
@logger.error( cmd + " Timed out : " )
rescue Exception => detail
@logger.error("Error during Processing #{cmd}
\n" + detail.message + detail.backtrace.join("\n") )
ensure
Thread.exit
end
end
}
end

Some of the tasks are calls to the backtick operator for shell functions.

If a backtick operation times out the thread is not killed. I can
watch the process list and see that the process is running, the logger
tells me when it started and when it should be forcefully terminated
but the thread just stays there. Once the task is finished it prints
the "timed out" message so obviously the exception was raised but it
did not kill the eval and turn the control over to the script. Also
once the timeout has exceeded no new tasks are being threaded. It's
like the whole script is waiting for this one task to get done before
it can go any further.

Any ideas on how I can correct this code so that the running process
can get killed?

1 Answer

Roger Pack

3/14/2008 4:03:00 PM

0

Maybe use system or popen for the processes?
> Any ideas on how I can correct this code so that the running process
> can get killed?

--
Posted via http://www.ruby-....