Weird thread behavior in windows.

T

Tim Uckun

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top