Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > select.poll.poll() never blocks

Reply
Thread Tools

select.poll.poll() never blocks

 
 
birdsong
Guest
Posts: n/a
 
      02-12-2009
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.

Here's an example snippet:
>>> fd = os.open('/tmp/poll_test', os.O_RDONLY | os.O_SYNC)
>>> p = select.poll()
>>> p.register(fd, select.POLLIN)
>>> s = p.poll()
>>> os.read(fd, 10)

''
>>> s

[(3, 1)]
>>> fd

3

I was using the open builtin originally, but a forum I read suggested
that this created user level buffers that the system call wouldn't
know about(which didn't completely jive with me), so I switched to the
lower level os.open.

Am I not getting the proper spirit of select.poll? I know that read()
never blocks and I think I read somewhere that poll will return fd
that will not block for the EVENT registered -so in that regard it's
fitting.

Any help on what I'm missing would be appreciated.
 
Reply With Quote
 
 
 
 
Hendrik van Rooyen
Guest
Posts: n/a
 
      02-12-2009
"birdsong" <>wrote:

8<----------- select not blocking on empty file stuff -----------------

> Any help on what I'm missing would be appreciated.


Why do you expect it to block?
It is ready to read, to return end of file.

- Hendrik


 
Reply With Quote
 
 
 
 
birdsong
Guest
Posts: n/a
 
      02-12-2009
On Feb 11, 10:36*pm, "Hendrik van Rooyen" <m...@microcorp.co.za>
wrote:
> "birdsong" <dav...@gmail.com>wrote:
>
> 8<----------- select not blocking on empty file stuff -----------------
>
> > Any help on what I'm missing would be appreciated.

>
> Why do you expect it to block?
> It is ready to read, to return end of file.
>

I expected it to block because of the name and meaning of the flag,
POLLIN, which I thought meant new data has arrived to be read. Since
I only registered a single file descriptor, I would have expected poll
to not return until there was new data to be read. I understand now
that it is not the case.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
You've never seen it before and you'll never see it again. Fred A Stover Computer Support 7 12-26-2007 03:33 AM
XML Schema never-never occurence of declared elements / attributes Soren Kuula XML 1 12-01-2005 01:27 PM
procs/blocks - blocks with procs, blocks with blocks? matt Ruby 1 08-06-2004 01:33 AM
string routines go to never never land on unix Kevin C Programming 4 10-17-2003 06:07 PM



Advertisments