From: Yehuda Katz Date: 2011-08-02T09:02:10+09:00 Subject: [ruby-core:38678] [Ruby 1.9 - Bug #5138] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK Issue #5138 has been updated by Yehuda Katz. File try_nonblock.diff added Here's an updated patch that returns nil for EOF and replaces the kgio variable with no_exceptions. The docs and tests are updated as well. ---------------------------------------- Bug #5138: Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK http://redmine.ruby-lang.org/issues/5138 Author: Yehuda Katz Status: Open Priority: Normal Assignee: Yukihiro Matsumoto Category: core Target version: 1.9.4 ruby -v: - The current Ruby I/O classes have non-blocking methods (read_nonblock and write_nonblock). These methods will never block, and if they would block, they raise an exception instead (IO::WaitReadable or IO::WaitWritable). In addition, if the IO is at EOF, they raise an EOFError. These exceptions are raised repeatedly in virtually every use of the non-blocking methods. This patch adds a pair of methods (try_read_nonblock and try_write_nonblock) that have the same semantics as the existing methods, but they return Symbols instead of raising exceptions for these routine cases: * :read_would_block * :write_would_block * :eof The patch contains updates for IO, StringIO, and OpenSSL. The updates are fully documented and tested. -- http://redmine.ruby-lang.org