- # override this one from the python 2.7 code
- # originally defined in class TCPServer
- def shutdown_request(self, request):
- """
- Called to shutdown and close an individual request.
- """
- # ----------
- # the std python 2.7 code just attempts a
- # request.shutdown(socket.SHUT_WR)
- # this works fine with regular sockets
- # However we are dealing with an instance of
- # OpenSSL.SSL.Connection instead
- # This one only supports shutdown(), and in addition this does not
- # always perform as expected
- # ---------- std python 2.7 code
- try:
- # explicitly shutdown. socket.close() merely releases
- # the socket and waits for GC to perform the actual close.
- request.shutdown(socket.SHUT_WR)
- except socket.error:
- pass # some platforms may raise ENOTCONN here
- # ----------
- except TypeError:
- # we are dealing with an OpenSSL.Connection object,
- # try to shut it down but never mind if that fails
- try:
- request.shutdown()
- except:
- pass
- # ----------
- self.close_request(request)