select.epoll question

Paul Rubin no.email at nospam.invalid
Thu Feb 7 02:08:24 EST 2013


I'm trying to listen to a bunch of sockets using epoll under Linux, e.g.

   import select, socket
   socket1 = socket.socket() ...

   p = select.epoll()
   p.register(socket1); p.register(socket2); ...
   result = p.poll()

This returns `result' as a list of 2-tuples (fd, status) where fd
is a Linux file descriptor, i.e. a small integer like comes back 
from socket.fileno().  That's different from select.select, which
returns a list of actual socket objects that I can read from with
socket.recv().  

Any idea of a good way to map the file descriptors back to socket
objects?  Is there some kind of hidden interface that I don't know
about, that gives back sockets directly?

The docs for epoll in select.html don't seem very good.  I haven't
yet examined the source code.

Thanks for any advice.

--Paul



More information about the Python-list mailing list