[#108552] [Ruby master Bug#18782] Race conditions in autoload when loading the same feature with multiple threads. — "ioquatix (Samuel Williams)" <noreply@...>
Issue #18782 has been reported by ioquatix (Samuel Williams).
11 messages
2022/05/14
[ruby-core:108551] [Ruby master Feature#17363] Timeouts
From:
"Eregon (Benoit Daloze)" <noreply@...>
Date:
2022-05-14 09:06:39 UTC
List:
ruby-core #108551
Issue #17363 has been updated by Eregon (Benoit Daloze).
marcandre (Marc-Andre Lafortune) wrote in #note-10:
> We could also define `::TimeoutError` as base class, and modify `timeout` lib so that `Timeout::Error < ::TimeoutError` instead of `==` as it is currently.
I think there is actually no use case for that besides "it looks nice/unified".
In practice if one rescues some kind of timeout I think they should use a specific class.
If they want to rescue "anything" and retry then `rescue StandardError` (or just `rescue`) covers better than just ::TimeoutError.
BTW, Regexp::TimeoutError is (currently) < RegexpError < StandardError, so it can't < `::TimeoutError` unless it no longer < RegexpError.
----------------------------------------
Feature #17363: Timeouts
https://bugs.ruby-lang.org/issues/17363#change-97592
* Author: marcandre (Marc-Andre Lafortune)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
----------------------------------------
Builtin methods like `Queue.pop` and `Ractor.receive` have no timeout parameter.
We should either:
- provide such a parameter
- and/or provide a `Timeout::wake` that raises an timeout error only if the block is currently sleeping.
Details:
```ruby
q = Queue.new
# ...
elem = Timeout::timeout(42) { q.pop } # => It is possible that an element is retreived from the queue but never stored in `elem`
elem = Timeout::wake(42) { q.pop } # => Guaranteed that either element is retrieved from the queue or an exception is raised, never both
Timeout::wake(42) { loop {} } # => infinite loop
# and/or
elem = q.pop(timeout: 42)
```
Currently, the only reliable way to have a Queue that accepts a timeout is to re-implement it from scratch. This post describe how involved that can be: https://spin.atomicobject.com/2017/06/28/queue-pop-with-timeout-fixed/
--
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>