def _do_tls_handshake(self):
logger.debug("<STR_LIT>")<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>self.sock.do_handshake()<EOL>break<EOL><DEDENT>except ssl.SSLError as err:<EOL><INDENT>if err.args[<NUM_LIT:0>] == ssl.SSL_ERROR_WANT_READ:<EOL><INDENT>select.select([self.sock], [], [])<EOL><DEDENT>elif err.args[<NUM_LIT:0>] == ssl.SSL_ERROR_WANT_WRITE:<EOL><INDENT>select.select([], [self.sock], [])<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>logger.debug("<STR_LIT>")<EOL>self.extra_on_read = None<EOL>self.write_enabled = True<EOL>self.write_cond.notify()<EOL>
Do the TLS handshake. Called from the reader thread
        after `starttls` is called.