parameters: (self)
docstring: Close the connection without assuming anything about it.
docstring_summary: Close the connection without assuming anything about it.
docstring_tokens: Close the connection without assuming anything about it .
function: def close(self):
          """Close the connection without assuming anything about it."""
          try:
              file = self.file
              self.file = None
              if file is not None:
                  file.close()
          finally:
              sock = self.sock
              self.sock = None
              if sock is not None:
                  try:
                      sock.shutdown(socket.SHUT_RDWR)
                  except OSError as exc:
                      # The server might already have closed the connection.
                      # On Windows, this may result in WSAEINVAL (error 10022):
                      # An invalid operation was attempted.
                      if (exc.errno != errno.ENOTCONN
                         and getattr(exc, 'winerror', 0) != 10022):
                          raise
                  finally:
                      sock.close()
function_tokens: def close ( self ) : try : file = self . file self . file = None if file is not None : file . close ( ) finally : sock = self . sock self . sock = None if sock is not None : try : sock . shutdown ( socket . SHUT_RDWR ) except OSError as exc : # The server might already have closed the connection. # On Windows, this may result in WSAEINVAL (error 10022): # An invalid operation was attempted. if ( exc . errno != errno . ENOTCONN and getattr ( exc , 'winerror' , 0 ) != 10022 ) : raise finally : sock . close ( )