[#106355] [Ruby master Bug#18373] RBS build failure: '/include/x86_64-linux/ruby/config.h', needed by 'constants.o'. — "vo.x (Vit Ondruch)" <noreply@...>
Issue #18373 has been reported by vo.x (Vit Ondruch).
28 messages
2021/12/01
[ruby-core:106369] [Ruby master Bug#18375] Timeout.timeout(sec, klass: MyExceptionClass) can not retry correctly.
From:
"jeremyevans0 (Jeremy Evans)" <noreply@...>
Date:
2021-12-01 21:41:20 UTC
List:
ruby-core #106369
Issue #18375 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Rejected
I don't think this is a bug, and I don't think timeout can work with your proposed code. There's no way the block-level `rescue` can work the way you want, since what you want requires the `timeout` method be called again.
This code:
```ruby
Timeout.timeout(2, DelayError) do |arg|
puts 'start'
sleep 10
rescue DelayError
puts '*'*10
retry
end
```
is short for:
```ruby
Timeout.timeout(2, DelayError) do |arg|
begin
puts 'start'
sleep 10
rescue DelayError
puts '*'*10
retry
end
end
```
It's not short for:
```ruby
begin
Timeout.timeout(2, DelayError) do |arg|
puts 'start'
sleep 10
end
rescue DelayError
puts '*'*10
retry
end
```
Even if it were short for that, that code doesn't work the way you want either (looks like an infinite loop). You probably want something like:
```ruby
deadline = Time.now + 10
begin
Timeout.timeout(2, DelayError) do |arg|
puts 'start'
sleep(deadline - Time.now)
end
rescue DelayError
puts '*'*10
retry
end
```
----------------------------------------
Bug #18375: Timeout.timeout(sec, klass: MyExceptionClass) can not retry correctly.
https://bugs.ruby-lang.org/issues/18375#change-95004
* Author: zw963 (Wei Zheng)
* Status: Rejected
* Priority: Normal
* ruby -v: 3.0.3
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Following is a example for describe this issue.
```rb
class DelayError < Exception
end
Timeout.timeout(2, DelayError) do |arg|
puts 'start'
sleep 10
rescue DelayError
puts '*'*10
retry
end
```
Will output
```
start
**********
start
```
What i expected is:
```
start
**********
start
**********
start
**********
...
```
Basically, what i expected equivalent is:
```rb
begin
Timeout.timeout(2) do |arg|
puts 'start'
sleep 10
end
rescue TimeoutError
puts '*'*10
retry
end
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>