English 中文(简体)
阅读“监视”
原标题:Ruby Thread with "watchdog"

I m 安装一个垃圾服务器,处理从全球垃圾处理系统单元制作的袖珍材料。 情况是,当单元的权力落下时,没有迹象表明书状已经关闭。

I m 做校服,用同一服务器处理多个袖珍。 我要求的是: 是否有办法在read子里使用一个时子,在每张材料之后重新铺开,如果它打上了时间,就关闭了路面? 在什么地方,我可以找到更多有关这方面的信息?

EDIT: 检测材料结存的编码实例

require  socket 

server = TCPServer.open(41000)
loop do
    Thread.start(server.accept) do |client|
        puts "Client connected"

        begin
            loop do
                line = client.readline

                open( log.txt ,  a ) { |f|
                    f.puts line.strip
                }
            end
        rescue
            puts "Client disconnected"
        end
    end
end 
问题回答

我认为,你需要一个心灵机制。

在座椅上,由于你不再追捕在遥远的封闭状态时提出的例外,您的袖珍被夸大。

你们需要把联手划入一个例外的集束区。

如果不了解什么模块/模型,你就只能判断它,并说你有“<条码>程序——连接<>。 因此,你们需要做这样的事情:

def process_connection(conn)
    begin
        # do stuff
    rescue Exception => e
        STDERR.print "Caught exception #{e}: #{e.message}
#{e.backtrace}
"
    ensure
        conn.close
    end
end

这将涵盖所有例外情形,并将它们丢弃,以 st痕 st。 从那里看,你会看到造成这些疾病的原因,并可能在其他地方更加宽松地处理。

仅检查安普森表的时间:

require  timeout 
status = Timeout::timeout(3){sleep(1)}
puts status.inspect
status = Timeout::timeout(1){sleep(2)}




相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签