def _handshake(self): try: self.socket.do_handshake(block=True) except (ssl.SSLWantReadError, ssl.SSLWantWriteError): pass