I'm writing a client/server application in Python and I'm finding it necessary to get a new connection to the server for each request from the client. My server is just inheriting from TCPServer and I'm inheriting from BaseRequestHandler to do my processing. I'm not calling self.request.close() anywhere in the handler, but somehow the server seems to be hanging up on my client. What's up?
Okay, I read the code (on my Mac, SocketServer.py is at /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/).
Indeed, TCPServer is closing the connection. In BaseServer.handle_request, process_request is called, which calls close_request.  In the TCPServer class, close_request calls self.request.close(), and self.request is just the socket used to handle the request.
So the answer to my question is "Yes".
Does the TCPServer + BaseRequestHandler in Python's SocketServer close the socket after each call to handle()?