[Python-bugs-list] [ python-Bugs-424951 ] ThreadingTCPServer file handle errors.

noreply@sourceforge.net noreply@sourceforge.net
Tue, 10 Jul 2001 05:03:02 -0700


Bugs item #424951, was opened at 2001-05-17 12:31
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=424951&group_id=5470

>Category: Python Library
Group: None
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Jeff Largent (jlargent)
Assigned to: Guido van Rossum (gvanrossum)
Summary: ThreadingTCPServer file handle errors.

Initial Comment:
When running a server using ThreadingTCPServer if the
server sit for several minutes between requests the
first request it receives will error with a bad file
handle error.

Python 2.1 (#1, Apr 20 2001, 15:04:11) 
[GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2

#!/usr/bin/python2

from SocketServer import ThreadingTCPServer,
BaseRequestHandler



class myHandler (BaseRequestHandler):
    def handle(self):
        while 1:
            data = self.request.recv(1024)
            if not data: break
            
            self.request.send('%s' % (data))
            
        self.request.close

if __name__ == '__main__':
    addr = ('localhost', 50000)
    s = ThreadingTCPServer(addr, myHandler)
    s.serve_forever()

Start this server wait several min then
using the echo-client.py from oreilly Programming
Python to 
send it data.

Traceback (most recent call last):
  File
"/var/tmp/python2-2.1-root/usr/lib/python2.1/threading.py",
line 378, in __bootstrap
    self.run()
  File
"/var/tmp/python2-2.1-root/usr/lib/python2.1/threading.py",
line 366, in run
    apply(self.__target, self.__args, self.__kwargs)
  File
"/var/tmp/python2-2.1-root/usr/lib/python2.1/SocketServer.py",
line 246, in finish_request
    self.RequestHandlerClass(request, client_address,
self)
  File
"/var/tmp/python2-2.1-root/usr/lib/python2.1/SocketServer.py",
line 495, in __init__
    self.handle()
  File "./server.py", line 10, in handle
    data = self.request.recv(1024)
error: (9, 'Bad file descriptor')

Any requests sent right after this will complete
properly.



----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-10 04:57

Message:
Logged In: YES 
user_id=6380

I've eproduced this and have now produced a fix.  Check out
the latest
SocketServer.py from the CVS!


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=424951&group_id=5470