[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:108149] [Ruby master Feature#18630] Introduce general `IO#timeout` and `IO#timeout=`for a
From:       "ioquatix (Samuel Williams)" <noreply () ruby-lang ! org>
Date:       2022-03-31 22:52:07
Message-ID: redmine.journal-97123.20220331225206.3344 () ruby-lang ! org
[Download RAW message or body]

Issue #18630 has been updated by ioquatix (Samuel Williams).


> many of functions involved above don't ever return ETIMEDOUT, so it would be \
> incorrect/surprising to reuse it for that.

The reality is, some functions **do** return this and so we should consider how it \
impacts users who want to handle **all** IO timeouts. Having two distinct exceptions \
seems a little messy to me. I'm happy to accept these are different, but I'm also \
suggesting we should consider carefully the implications of this choice.

Basically, do we want users to write:

```
rescue IO::TimeoutError, Errno::ETIMEDOUT
```

???

----------------------------------------
Feature #18630: Introduce general `IO#timeout` and `IO#timeout=`for all \
(non-)blocking operations. https://bugs.ruby-lang.org/issues/18630#change-97123

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
----------------------------------------
I would like us to consider introducing a general IO timeout for all (non-)blocking \
operations, specified per-IO instance. It's useful for ensuring programs don't stop \
responding or spend an unreasonable amount of time waiting for IO operations.

There are effectively two kinds of interfaces that we need to address:

- Those that already have a timeout argument (e.g. `wait_readable`) and we follow the \
                existing semantics.
- Those that don't have a timeout argument or timeout semantics (e.g. `puts`, \
`gets`), and thus probably need to raise an exception on timeout.

We have three possible kinds of exceptions we could raise:

- `Errno::ETIMEDOUT`
- `Timeout::Error` (from `timeout.rb`)
- Introduce `IO::Timeout` or something similar.

Timeout isn't necessarily an error condition. There are different arguments for \
whether we should define:

```ruby
class IO::Timeout < Exception
end

# or

class IO::Timeout < StandardError
end
```

I believe the latter (`StandardError`) is more practical but I'm open to either \
option. I might have more specific arguments later why one is better than the other \
after testing in a practical system.

There is already a PR to try it out: https://github.com/ruby/ruby/pull/5653



-- 
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>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic