From: Aaron Patterson Date: 2011-08-04T02:54:22+09:00 Subject: [ruby-core:38762] Re: [Ruby 1.9 - Bug #5138][Open] Add nonblocking IO that does not use exceptions for EOF and EWOULDBLOCK --oC1+HKm2/end4ao3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 03, 2011 at 11:03:09PM +0900, Tanaka Akira wrote: > 2011/8/2 Yehuda Katz : >=20 > > The current Ruby I/O classes have non-blocking methods (read_nonblock a= nd write_nonblock). These methods will never block, and if they would block= , they raise an exception instead (IO::WaitReadable or IO::WaitWritable). I= n addition, if the IO is at EOF, they raise an EOFError. > > > > These exceptions are raised repeatedly in virtually every use of the no= n-blocking methods. This patch adds a pair of methods (try_read_nonblock an= d try_write_nonblock) that have the same semantics as the existing methods,= but they return Symbols instead of raising exceptions for these routine ca= ses: >=20 > I'm neutral about this proposal. >=20 > Although the exceptions are not exceptional, > they are very educational. If the exceptions are not exceptional, that makes me wonder why are they exceptions at all? Since these aren't really exceptional cases, I would prefer not to rescue. As Alex pointed out, these exceptions really make $DEBUG noisy and that also bugs me about the current behavior. --=20 Aaron Patterson http://tenderlovemaking.com/ --oC1+HKm2/end4ao3 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJOOYtDAAoJEJUxcLy0/6/G25sIAIGeZUyfvdlavV6CRc+NSh7d qmjNIC4284htECvwkLRMwrH+sDh4ANS/CZ+yfqOKq3qduTb8jO1BIcPYAce/0Okh RXQ3xjd5STDcA1gDBJNqsgWI9bcHSwBFCIb5nX+b2EwZCc6PEON60hPgrXb3T0Cj LACYnNDno1OlykzSOl1oXV/N/KqO5ttp6Zbd+efpTRgw1Sj9/dl2MUgakS8CREWd J3hyUcDBGLGmOY9ZmgXsFijzUUDVI+Dmxzl6GHZddbjF7/AEX5klj6soUq+eRLgj +HkbB7IT2Ej5k0fXEr3z7yMTOZTnD1AKR6mjAdzfzs/w6Lwdo2IjXhkXsR+VEOE= =CJ9G -----END PGP SIGNATURE----- --oC1+HKm2/end4ao3--