def starttls(self, *args, **kwargs):
kwargs['<STR_LIT>'] = False<EOL>with self.lock:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>while self.wdata:<EOL><INDENT>self.write_cond.wait()<EOL><DEDENT>self.write_enabled = False<EOL>self.write_cond.notify()<EOL>logger.debug("<STR_LIT>")<EOL>self.sock = ssl.wrap_socket(*args, **kwargs)<EOL>self.extra_on_read = self._do_tls_handshake<EOL>self.rdata = b"<STR_LIT>"<EOL><DEDENT>
Request switching to TLS.

        First waits untill all currently buffered data is sent.

        :Parameters:
            - `args`: positional arguments to :std:`ssl.wrap_socket`
            - `kwargs`: keyword arguments to :std:`ssl.wrap_socket`