ValueError: filedescriptor out of range in select()



This is a long running process, written in Python. Only standard lib is used. This process accepts connections on TCP sockets, read/write data.

After about one day, it starts throwing this when I try to connect:

2009-03-17 09:49:50,096 INFO .accesspoint0 ('127.0.0.1', 55510) connecting
2009-03-17 09:49:50,097 ERROR .accesspoint0 Traceback (most recent call last):
File "/usr/local/www/vhosts/shopzeus.com/fantasy/sorb/accesspoints/srvtcp.py", line 34, in handle_request
t = sorb.endpoint.SocketEndpoint(conn,self.router)
File "/usr/local/www/vhosts/shopzeus.com/fantasy/sorb/endpoint.py", line 304, in __init__
StreamEndpoint.__init__(self,router)
File "/usr/local/www/vhosts/shopzeus.com/fantasy/sorb/endpoint.py", line 133, in __init__
self.format = self.read_str() # determine remote format
File "/usr/local/www/vhosts/shopzeus.com/fantasy/sorb/endpoint.py", line 236, in read_str
size = self.read_long()
File "/usr/local/www/vhosts/shopzeus.com/fantasy/sorb/endpoint.py", line 222, in read_long
return struct.unpack(">q",self.read_data(8))[0]
File "/usr/local/www/vhosts/shopzeus.com/fantasy/sorb/endpoint.py", line 344, in read_data
ready = select.select([fd], [], [], 0.2)
ValueError: filedescriptor out of range in select()


The code for read_data:

def read_data(self,size):
res = ""
fd = self.socket.fileno()
while not self.stop_requested.isSet():
remaining = size - len(res)
if remaining<=0:
break
# Give one second for an incoming connection so we can stop the
# server in seconds when needed
ready = select.select([fd], [], [], 0.2)
if fd in ready[0]:
data = self.socket.recv(min(remaining,8192)) # 8192 is recommended by socket.socket manual.
if not data:
# select returns the fd but there is no data to read -> connection closed!
self.shutdown()
raise TransportClosedError("Connection closed.")
else:
res += data
else:
pass
if self.stop_requested.isSet():
self.shutdown()
raise TransportClosedError()
return res


If I telnet this server this is what I see:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.


E.g. the connection is closed instantly after the connection has been made. For some reason, the client socket on the server side has an invalid fileno, and it cannot be passed to select.select(). I found some articles on the internet about this error, but nothing useful about how to solve it.

Please help.

Laszlo

.



Relevant Pages

  • Re: Outgoing POP3 email missing/lost/not received
    ... Funny thing is that I have had this ISP for 8 years and it has always been ... It looks like when you last ran CEICW, you set the ISP's mail server to: ... Internet Connection Wizard. ... After the wizard completes, the following network connection ...
    (microsoft.public.windows.server.sbs)
  • Re: Cannot connect client to server 2003
    ... you need to reconfigure the IP schema of your SBS ... On the SBS 2003 Server open the Server Management console. ... On the Connection Type page, click Broadband, and then click Next. ... Alternate DNS server, type the IP addresses that are provided by your ISP ...
    (microsoft.public.windows.server.sbs)
  • Re: Outgoing POP3 email missing/lost/not received
    ... ISP's mail server instead of the domain name on the ... SUMMARY OF SETTINGS FOR CONFIGURE E-MAIL AND INTERNET ... Internet Connection Wizard. ... After the wizard completes, the following network connection ...
    (microsoft.public.windows.server.sbs)
  • Re: Networking Question - VLANs on SBS 2003 Premium SP1
    ... port on the old router so I now have a segregated WLAN. ... be sure you do not enable any DHCP server in internal network. ... On the Connection Type page, click Broadband, and then click Next. ... On the Network Connection, You must enable and configure the network ...
    (microsoft.public.windows.server.sbs)
  • Re: Still cant connect to RWW or OWA remotely
    ... it certainly appears to be something about the SBS configuration. ... Meridian.local Ethernet adapter Local Area Connection: ... Windows SMALL BUSINESS SERVER 2003 Windows IP Configuration ... 192.168.254.254) directly to a port on the router and then ...
    (microsoft.public.windows.server.sbs)

Loading