From: "headius (Charles Nutter)" Date: 2013-04-24T05:25:10+09:00 Subject: [ruby-core:54531] [ruby-trunk - Feature #5138] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK Issue #5138 has been updated by headius (Charles Nutter). Trying to kick this one forward. I'm going to implement this in JRuby, perhaps via an ext (require 'io/try_nonblock' or something). It will give an opportunity to play with the API in-place using JRuby master builds or JRuby 1.7.4+. Will report some results once I get it implemented. ---------------------------------------- Feature #5138: Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK https://bugs.ruby-lang.org/issues/5138#change-38846 Author: wycats (Yehuda Katz) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor 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://bugs.ruby-lang.org/