[Gllug] poll() & python

Pete Ryland pdr at pdr.cx
Tue Nov 27 14:14:32 UTC 2001


POLLERR, POLLHUP and POLLNVAL are meaningless in the (incoming) events
field.  They only have significance in the (outgoing) revents field.

Pete

On Tue, Nov 27, 2001 at 01:59:53PM +0000, ab wrote:
> Hey,
> Anyone using Python out there ?
> Try to do asynchronous I/O on a socket... using the poll() system call
> (reading the man page it says that poll is more efficient than select).
> However once connection is made, it always returns data ready to be
> read (POLLIN flag), and always returns immediately with no timeout.
> The client has hungup already and reading gives 0 bytes ??????
> 
> Sample code:
> 
>                 poller.register(conn.fileno(),select.POLLIN | select.POLLERR
> | select.POLLHUP | select.POLLNVAL)
>                 while 1:
>                     result = poller.poll(5000)
>                     if result == []:
>                         break
>                     fd,event = result[0]
>                     if event == select.POLLIN:
>                         str = conn.recv(1024)
>                         print len(str)
>                         print str
>                     else:
>                         break
>                 poller.unregister(conn.fileno())
> 
> Anyone used poll before ? its got me foxed !
> 
> /Anthony/
> 
> 
> -- 
> Gllug mailing list  -  Gllug at linux.co.uk
> http://list.ftech.net/mailman/listinfo/gllug
> 

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list