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 <rep...@bugs.python.org>
<http://bugs.python.org/issue16853>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to