mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert r38216 and r38221. Release manager mark this feature as "next minor".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
65129f3a5d
commit
3bbffbc7dd
4 changed files with 18 additions and 106 deletions
|
@ -18,7 +18,7 @@ class TestTimeout < Test::Unit::TestCase
|
|||
}
|
||||
assert_nothing_raised("[ruby-dev:38319]") do
|
||||
Timeout.timeout(1) {
|
||||
sleep 0.01 while @flag
|
||||
nil while @flag
|
||||
}
|
||||
end
|
||||
assert !@flag, "[ruby-dev:38319]"
|
||||
|
@ -29,66 +29,4 @@ class TestTimeout < Test::Unit::TestCase
|
|||
def (n = Object.new).zero?; false; end
|
||||
assert_raise(TypeError, bug3168) {Timeout.timeout(n) { sleep 0.1 }}
|
||||
end
|
||||
|
||||
def test_timeout_immediate
|
||||
begin
|
||||
t = Thread.new {
|
||||
Timeout.timeout(0.1, immediate: true) {
|
||||
# loop forever, but can be interrupted
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
sleep 0.5
|
||||
t.raise RuntimeError
|
||||
assert_raise(Timeout::Error) {
|
||||
t.join
|
||||
}
|
||||
ensure
|
||||
t.kill if t.alive?
|
||||
begin
|
||||
t.join
|
||||
rescue Exception
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_timeout_immediate2
|
||||
begin
|
||||
t = Thread.new {
|
||||
Timeout.timeout(0.1) {
|
||||
# loop forever, must not interrupted
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
sleep 0.5
|
||||
t.raise RuntimeError
|
||||
assert_raise(Timeout::Error) {
|
||||
# deferred interrupt should raise
|
||||
t.join
|
||||
}
|
||||
ensure
|
||||
t.kill if t.alive?
|
||||
begin
|
||||
t.join
|
||||
rescue Exception
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_timeout_blocking
|
||||
t0 = Time.now
|
||||
begin
|
||||
Timeout.timeout(0.1) {
|
||||
while true do
|
||||
t1 = Time.now
|
||||
break if t1 - t0 > 1
|
||||
end
|
||||
sleep 2
|
||||
}
|
||||
rescue Timeout::Error
|
||||
end
|
||||
t1 = Time.now
|
||||
assert (t1 - t0) >= 1
|
||||
assert (t1 - t0) < 2
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue