python select() is limited to fds < 64
Jon TURNEY
jon.turney@dronecode.org.uk
Tue Mar 22 19:50:00 GMT 2011
python seems to be built with the default value of FD_SETSIZE, which is only
64 on cygwin.
I noticed this as it causes numerous tests in the twisted test suite to fail
with "ValueError: filedescriptor out of range in select()" exceptions, but can
also be demonstrated with a simple test case:
$ cat select_test.py
from socket import *
from select import select
ins = []
for i in range(1024):
s = socket(AF_INET, SOCK_STREAM)
ins.append(s)
print "socket opened with fd", s.fileno()
select(ins, [], [], 0)
$ python select_test.py
[...]
socket opened with fd 64
Traceback (most recent call last):
File "./select_test.py", line 11, in <module>
select(ins, [], [], 0)
ValueError: filedescriptor out of range in select()
Looking at the source [1], note that steps are already taken to increase the
default value of FD_SETSIZE on Win32, and I'd suggest it's appropriate to do
the same on cygwin, patch attached.
Note some code motion is necessary as FD_SETSIZE must be defined before
sys/types.h is included if we are going to override the default value set there.
I don't believe this can cause any ABI issues as the interface is in terms of
python lists, rather than fd_set values.
[1] http://hg.python.org/cpython/file/3c0edb157ea2/Modules/selectmodule.c
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 2.6.5-FD_SETSIZE.patch
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110322/99b31f36/attachment.ksh>
-------------- next part --------------
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list