SiteSupport/gevent — pull request #164 by vitaly-krugl (2012-09-24 05:39:20+00:00)
Title: Fixes for issue #146 and issue #147

This is a new attempt at fixes for issues #147 and #146 that addresses Denis's concerns about two additional syscalls per I/O operations when FileObjectPosix is used from the original use case of gevent.subprocess.Popen. It also contains a TODO comment in fileobject.py that calls out a couple of issues in the existing code (unrelated to #147 and #146) that I think should also be addressed.

Fixed issue #147 ("FileObject(stdin) causes os.write on stdout to fail with OSError: [Errno 35]
Resource temporarily unavailable") by adding an optional arg restore_flags to FileObjectPosix
constructor. This enables an efficient default case (restore_flags=False, such as FileObject's
use in gevent.subprocess.Popen), while enabling FileObjectPosix to also be used for stdin, etc.
without causing unexpected failures in stdout I/O. Implemented test_fcntl_flags_preserved() in
test__fileobject.py.

Fixed issue #146 ("FileObject incorrectly reports end of file when file descriptor is closed
prematurely"). NOTE: this was fixed in teh same commit as #147 due to rewrite in the same block
of code. Implemented test_EBADF_from_read_with_fd_closed() in test__fileobject.py.