select.poll.poll() never blocks

birdsong david.birdsong at gmail.com
Wed Feb 11 22:01:16 EST 2009


So I guess I didn't have a complete understanding of poll, I thought
it returned file descriptors that had registered an event that the
user asked to watch for.  In my case, select.POLLIN
Constant 	Meaning
POLLIN 	There is data to read

...there ins't any data to be read.  The file is readable, yes, but is
that all that the syscall has to offer?


On Feb 11, 6:49 pm, Jean-Paul Calderone <exar... at divmod.com> wrote:
> On Wed, 11 Feb 2009 18:44:53 -0800 (PST), birdsong <david.birds... at gmail.com> wrote:
> >I'm pretty sure I've exhausted all searches and read all the forums
> >Google will turn up related to this issue.
>
> >I touch an empty file in a sh shell, fire up the python shell, open
> >the file for reading(tried all buffering options), register it with a
> >poll object for select.POLLIN and call poll(), but the poll never
> >blocks and always returns for the FD, EVENT combination I ask for, but
> >the file has not anything written to it.
>
> Filesystem files are always reported as readable and writeable by select,
> poll, epoll, etc.
>
> If you want to do non-blocking filesystem I/O, your choices are to use a
> native thread (Python's threading module, or another third-party module
> which wraps the platform thread API) or to use POSIX AIO (or the mildly
> incompatible Linux variant.  Of course, AIO has tons of caveats and is
> generally in a miserable state, so you probably shouldn't use it.  That
> leaves you with threads.
>
> Jean-Paul




More information about the Python-list mailing list