This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ThreadingTCPServer file handle errors.
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, jlargent
Priority: normal Keywords:

Created on 2001-05-17 19:31 by jlargent, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (2)
msg4783 - (view) Author: Jeff Largent (jlargent) Date: 2001-05-17 19:31
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.

msg4784 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-07-10 11:57
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!
History
Date User Action Args
2022-04-10 16:04:04adminsetgithub: 34515
2001-05-17 19:31:25jlargentcreate