[New-bugs-announce] [issue16853] add a Selector to the select module

Charles-François Natali report at bugs.python.org
Thu Jan 3 18:38:06 CET 2013


New submission from Charles-François Natali:

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

----------
components: Library (Lib)
files: selector.diff
keywords: patch
messages: 178970
nosy: giampaolo.rodola, neologix, pitrou
priority: normal
severity: normal
status: open
title: add a Selector to the select module
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file28546/selector.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16853>
_______________________________________


More information about the New-bugs-announce mailing list