Author neologix
Recipients giampaolo.rodola, neologix, pitrou
Date 2013-01-03.17:38:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za>
In-reply-to
Content
Recently, the multiprocessing and telnetlib modules have been patched to use poll() instead of select() when available (mainly for the FD_SETSIZE limitation):
http://bugs.python.org/issue10527
http://bugs.python.org/issue14635

This leads to code duplication (just have a look at the commits to convince yourself), and also it highlights the fact that the select module is too low-level: right now, there's no easy way to do portable and efficient I/O multiplexing. What's more, /dev/poll and epoll() support have been added recently, which can make one puzzled by the myriad of available options.

Therefore, to reduce code duplication, and make writing portable and efficient code easier, I suggest the addition of a new select.Selector() class, which offers a - hopefully - simple and consistent API.
It has the following advantages:
- portable
- consistent (select() accepts and returns file objects, whereas pol() only returns FD, the timeouts don't have the same units - seconds/milliseconds, etc).

You'll find a tentative implementation attached, with tests (but no docs).

I'm also attaching two patches, one for multiprocessing.connection and the other for telnetlib, to show the before/after.

I'd like to have your feedback, especially on those points:
- right now, Selector.select() returns a set of (fd, event mask). What do you think, would a bare list be OK?
- the current version doesn't retry on EINTR, and I'd like to catch it by default: what do you think
- since I use an abstract base class, I don't know how to have docstrings show up in the help
History
Date User Action Args
2013-01-03 17:38:07neologixsetrecipients: + neologix, pitrou, giampaolo.rodola
2013-01-03 17:38:06neologixsetmessageid: <1357234686.56.0.503079428281.issue16853@psf.upfronthosting.co.za>
2013-01-03 17:38:06neologixlinkissue16853 messages
2013-01-03 17:38:06neologixcreate