code: def do_handshake(self, timeout):
          'perform a SSL/TLS handshake'
          tout = _timeout(timeout)
          if not self._blocking:
              return self._sslobj.do_handshake()
  
          while 1:
              try:
                  return self._sslobj.do_handshake()
              except ssl.SSLError, exc:
                  if exc.args[0] == ssl.SSL_ERROR_WANT_READ:
                      self._wait_event(tout.now)
                      continue
                  elif exc.args[0] == ssl.SSL_ERROR_WANT_WRITE:
                      self._wait_event(tout.now, write=True)
                      continue
                  raise
  
          self._wait_event(timeout)
          self._sslobj.do_handshake(f do_handshake(self, timeout):
          'perform a SSL/TLS handshake'
          tout = _timeout(timeout)
          if not self._blocking:
              return self._sslobj.do_handshake()
  
          while 1:
              try:
                  return self._sslobj.do_handshake()
              except ssl.SSLError, exc:
                  if exc.args[0] == ssl.SSL_ERROR_WANT_READ:
                      self._wait_event(tout.now)
                      continue
                  elif exc.args[0] == ssl.SSL_ERROR_WANT_WRITE:
                      self._wait_event(tout.now, write=True)
                      continue
                  raise
  
          self._wait_event(timeout)
          self._sslobj.do_handshake()
docs: perform a SSL/TLS handshake