Message179142
> I think that this needs extensive tests that verify the behavior of many end cases, including under duress (e.g. when there are too many connections for the kernel to handle). That would seem the only way to make sure that the code is reliable across platforms. It is likely that you could borrow some ideas for test scenarios from Twisted.
Will do.
I'm adding a new version taking into account some of Giampaolo's remarks.
Also, the API now also allows passing a file descriptor or any object
with a `fileno()` method, since it will likely be useful.
To sum up, the API is:
def register(self, fileobj, events, data=None):
"""Register a file object.
Parameters:
fileobj -- file object
events -- events to monitor (bitwise mask of SELECT_IN|SELECT_OUT)
data -- attached data
"""
def unregister(self, fileobj):
"""Unregister a file object.
Parameters:
fileobj -- file object
"""
def modify(self, fileobj, events, data=None):
"""Change a registered file object monitored events or attached data.
Parameters:
fileobj -- file object
events -- events to monitor (bitwise mask of SELECT_IN|SELECT_OUT)
data -- attached data
"""
def select(self, timeout=None):
"""Perform the actual selection, until some monitored file objects are
ready or a timeout expires.
Parameters:
timeout -- if timeout > 0, this specifies the maximum wait time, in
seconds
if timeout == 0, the select() call won't block, and will
report the currently ready file objects
if timeout is None, select() will block until a monitored
file object becomes ready
Returns:
list of (fileobj, events, attached data) for ready file objects
`events` is a bitwise mask of SELECT_IN|SELECT_OUT
Selector.select() output looks a lot like poll()/epoll() except for
two details: the output is the file object, and not the file
descriptor (poll()/epoll() are unfortunately inconsistent in this
regard), and there's a third field, the attached data (will be None if
not provided in register()/modify()). I think that this optional field
is really useful to pass e.g. a callback or some context information. |
|
Date |
User |
Action |
Args |
2013-01-05 20:23:27 | neologix | set | recipients:
+ neologix, gvanrossum, pitrou, giampaolo.rodola, christian.heimes, rosslagerwall, felipecruz |
2013-01-05 20:23:27 | neologix | link | issue16853 messages |
2013-01-05 20:23:27 | neologix | create | |
|