def starttls(self, **kwargs):
with self.lock:<EOL><INDENT>self.event(TLSConnectingEvent())<EOL>self._write_queue.append(StartTLS(**kwargs))<EOL>self._write_queue_cond.notify()<EOL><DEDENT>
Request a TLS handshake on the socket ans switch
        to encrypted output.
        The handshake will start after any currently buffered data is sent.

        :Parameters:
            - `kwargs`: arguments for :std:`ssl.wrap_socket`