X7ROOT File Manager
Current Path:
/opt/alt/ruby18/lib64/ruby/1.8
opt
/
alt
/
ruby18
/
lib64
/
ruby
/
1.8
/
??
..
??
English.rb
(5.6 KB)
??
Env.rb
(274 B)
??
abbrev.rb
(2.5 KB)
??
base64.rb
(3.37 KB)
??
benchmark.rb
(17.73 KB)
??
bigdecimal
??
cgi
??
cgi-lib.rb
(6.89 KB)
??
cgi.rb
(73.74 KB)
??
complex.rb
(12.84 KB)
??
csv.rb
(24.46 KB)
??
date
??
date.rb
(53.02 KB)
??
date2.rb
(128 B)
??
debug.rb
(20.61 KB)
??
delegate.rb
(8.81 KB)
??
digest
??
digest.rb
(1.12 KB)
??
dl
??
drb
??
drb.rb
(19 B)
??
e2mmap.rb
(4.04 KB)
??
erb.rb
(21.38 KB)
??
eregex.rb
(487 B)
??
expect.rb
(633 B)
??
fileutils.rb
(42.23 KB)
??
finalize.rb
(5.38 KB)
??
find.rb
(1.84 KB)
??
forwardable.rb
(6.16 KB)
??
ftools.rb
(6.17 KB)
??
generator.rb
(8.1 KB)
??
getoptlong.rb
(14.88 KB)
??
getopts.rb
(2.25 KB)
??
gserver.rb
(6.43 KB)
??
importenv.rb
(590 B)
??
io
??
ipaddr.rb
(21.96 KB)
??
irb
??
irb.rb
(7.43 KB)
??
jcode.rb
(4.3 KB)
??
kconv.rb
(8.12 KB)
??
logger.rb
(17.59 KB)
??
mailread.rb
(1.28 KB)
??
mathn.rb
(5.42 KB)
??
matrix.rb
(27.21 KB)
??
md5.rb
(411 B)
??
mkmf.rb
(50.65 KB)
??
monitor.rb
(7.93 KB)
??
mutex_m.rb
(2.07 KB)
??
net
??
observer.rb
(5.15 KB)
??
open-uri.rb
(20.49 KB)
??
open3.rb
(2.1 KB)
??
openssl
??
openssl.rb
(575 B)
??
optparse
??
optparse.rb
(47.12 KB)
??
ostruct.rb
(3.35 KB)
??
parsearg.rb
(1.55 KB)
??
parsedate.rb
(1.33 KB)
??
pathname.rb
(29.39 KB)
??
ping.rb
(1.48 KB)
??
pp.rb
(15.97 KB)
??
prettyprint.rb
(18.33 KB)
??
profile.rb
(90 B)
??
profiler.rb
(1.59 KB)
??
pstore.rb
(11.15 KB)
??
racc
??
rational.rb
(12.05 KB)
??
rdoc
??
readbytes.rb
(835 B)
??
resolv-replace.rb
(1.55 KB)
??
resolv.rb
(56.83 KB)
??
rexml
??
rinda
??
rss
??
rss.rb
(504 B)
??
rubyunit.rb
(180 B)
??
runit
??
scanf.rb
(20.63 KB)
??
securerandom.rb
(4.27 KB)
??
set.rb
(27.08 KB)
??
sha1.rb
(418 B)
??
shell
??
shell.rb
(4.66 KB)
??
shellwords.rb
(3.99 KB)
??
singleton.rb
(8.08 KB)
??
soap
??
sync.rb
(6.09 KB)
??
tempfile.rb
(4.86 KB)
??
test
??
thread.rb
(104 B)
??
thwait.rb
(4.32 KB)
??
time.rb
(31.58 KB)
??
timeout.rb
(3 KB)
??
tmpdir.rb
(3.69 KB)
??
tracer.rb
(2.73 KB)
??
tsort.rb
(7.99 KB)
??
un.rb
(4.54 KB)
??
uri
??
uri.rb
(710 B)
??
weakref.rb
(2.68 KB)
??
webrick
??
webrick.rb
(811 B)
??
wsdl
??
x86_64-linux
??
xmlrpc
??
xsd
??
yaml
??
yaml.rb
(12.36 KB)
Editing: timeout.rb
#-- # = timeout.rb # # execution timeout # # = Copyright # # Copyright:: (C) 2000 Network Applied Communication Laboratory, Inc. # Copyright:: (C) 2000 Information-technology Promotion Agency, Japan # #++ # # = Description # # A way of performing a potentially long-running operation in a thread, and # terminating it's execution if it hasn't finished within fixed amount of # time. # # Previous versions of timeout didn't use a module for namespace. This version # provides both Timeout.timeout, and a backwards-compatible #timeout. # # = Synopsis # # require 'timeout' # status = Timeout::timeout(5) { # # Something that should be interrupted if it takes too much time... # } # module Timeout ## # Raised by Timeout#timeout when the block times out. class Error < Interrupt end class ExitException < ::Exception # :nodoc: end THIS_FILE = /\A#{Regexp.quote(__FILE__)}:/o CALLER_OFFSET = ((c = caller[0]) && THIS_FILE =~ c) ? 1 : 0 ## # Executes the method's block. If the block execution terminates before +sec+ # seconds has passed, it returns true. If not, it terminates the execution # and raises +exception+ (which defaults to Timeout::Error). # # Note that this is both a method of module Timeout, so you can 'include # Timeout' into your classes so they have a #timeout method, as well as a # module method, so you can call it directly as Timeout.timeout(). def timeout(sec, klass = nil) return yield if sec == nil or sec.zero? raise ThreadError, "timeout within critical session" if Thread.critical exception = klass || Class.new(ExitException) begin x = Thread.current y = Thread.start { begin sleep sec rescue => e x.raise e else x.raise exception, "execution expired" if x.alive? end } yield sec # return true rescue exception => e rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o (bt = e.backtrace).reject! {|m| rej =~ m} level = -caller(CALLER_OFFSET).size while THIS_FILE =~ bt[level] bt.delete_at(level) level += 1 end raise if klass # if exception class is specified, it # would be expected outside. raise Error, e.message, e.backtrace ensure if y and y.alive? y.kill y.join # make sure y is dead. end end end module_function :timeout end ## # Identical to: # # Timeout::timeout(n, e, &block). # # Defined for backwards compatibility with earlier versions of timeout.rb, see # Timeout#timeout. def timeout(n, e = nil, &block) # :nodoc: Timeout::timeout(n, e, &block) end ## # Another name for Timeout::Error, defined for backwards compatibility with # earlier versions of timeout.rb. TimeoutError = Timeout::Error # :nodoc: if __FILE__ == $0 p timeout(5) { 45 } p timeout(5, TimeoutError) { 45 } p timeout(nil) { 54 } p timeout(0) { 54 } p timeout(5) { loop { p 10 sleep 1 } } end
Upload File
Create Folder