how to get non-blocking file descriptors from a popen?
Donn Cave
donn at u.washington.edu
Fri Jan 25 12:29:25 EST 2002
Quoth "Gregory P. Smith" <gsmith-mysterymeat at mysterymeat-transmeta.com>:
| Using os.popen (or better, popen2.Popen4 objects), how can I switch the
| returned file objects to non-blocking io mode for appropriate use with
| select.poll?
You know,
- select & poll really use a file "descriptor" - they'll accept various
alternatives, but only when there's a callable fileno attribute to
return the file descriptor. And when you go that way, any input
through a file object is liable to buffer up data that select can't
see, so the file object is little or no use. Use os.read() instead.
- when you use select, that file descriptor does _not_ need to be
non-blocking. select's whole purpose is to tell you when I/O will
not block, so if you let it tell you when to read, non-blocking is
irrelevant.
Donn Cave, donn at u.washington.edu
More information about the Python-list
mailing list