Is thread dead?

M

Marcin Tyman

Hi guys,
Here is piece of my code:

----------------------------------------------------------
def executeAgent()

# establish telnet connection etc.

begin
begin
agent.cmd('String' => "a_command") do |c|
agentLogger.info(c.to_str) #logs to output as well as to
local file
end
rescue TimeoutError => e
#exception handling + logging
end
rescue Errno::ECONNRESET, Errno::ECONNABORTED => e
#exception handling + logging
end

#logging that this function is going to finish because end prompt was
met
end #executeAgent

agentTr = Thread.new do
begin
executeAgent(myLogger)
rescue Exception => e
print("#{__FILE__} #{__LINE__}: executeAgent - #{e}\n")
end
end

while true
#something
puts "agentTr alive" if agentTr.alive?
#something
end
----------------------------------------------------------------


agent.cmd('String' => "a_command") - should never end, so logging to
local file everything what a_command throws should (in theory) never
ends as well (if of course above exceptions wouldn't occur - Timeout,
ECONRESET etc.).
But unfortunately looks like agentTr suddenly evaporates (agentTr.alive?
returns false). Furthermore I've got none of logs from rescues blocks of
code and moreover from the end of executeAgent function. Additionally
I've got none of logs from Thread.new block.

Such situation appears after several hours (randomly)
What is going on? Maybe something is not correct with exceptions
handling or something like that.
If a_command finishes end prompt should be in my logs, if any timeout
occur (in case a_command is suspended) a log should be in logs as well
etc.

I will be appreciated for any help.

Thanks in advance.
MT
 

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
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top