3 ms·
Keep in mind that select basically sucks for handling more than a few sockets -- it's slow and limited to max. 1024 concurrent sockets (unless you change FD_SET
by metachris 16y ago
Keep in mind that select basically sucks for handling more than a few sockets -- it's slow and limited to max. 1024 concurrent sockets (unless you change FD_SETSIZE and recompile everything, which may cause unexpected bugs).
An almost always better choice is using epoll -- it's usually faster and can handle any number of concurrent sockets (up to a million and more).
* http://docs.python.org/library/select.html#edge-and-level-trigger-polling-epoll-objects http://docs.python.org/library/select.html#edge-and-level-tr...
* http://scotdoyle.com/python-epoll-howto.html http://scotdoyle.com/python-epoll-howto.html
* http://blog.urbanairship.com/blog/2010/08/24/c500k-in-action-at-urban-airship/ http://blog.urbanairship.com/blog/2010/08/24/c500k-in-action...
* http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-3 http://www.metabrew.com/article/a-million-user-comet-applica...
- almost 16y agoThis is assuming that performance is an issue, which I would guess is not the case for at least 90% of uses. For most cases I'd say ease of use and cross platform makes select "better" than epoll.
- endgame 16y agoThis is why I like libev, which has bindings to several languages (including python). It picks the best backend for watching FDs on a given system (epoll, select, ...). The support for timers, idle callbacks and so on is also very handy.