This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

python select() is limited to fds < 64

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

from socket import *
from select import select

ins = []

for i in range(1024):
    s = socket(AF_INET, SOCK_STREAM)
    print "socket opened with fd", s.fileno()
    select(ins, [], [], 0)

$ python
socket opened with fd 64
Traceback (most recent call last):
  File "./", 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.


Attachment: 2.6.5-FD_SETSIZE.patch
Description: Text document

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]