def handshake_in_memory(client_conn, server_conn):
 client_conn.set_connect_state()
 server_conn.set_accept_state()
 for conn in [client_conn, server_conn]:
  try:
   conn.do_handshake()
  except WantReadError:
   pass
 interact_in_memory(client_conn, server_conn)

def handshake_in_memory ( client_conn , server_conn ) : client_conn . set_connect_state ( ) server_conn . set_accept_state ( ) for conn in [ client_conn , server_conn ] : try : conn . do_handshake ( ) except WantReadError : pass interact_in_memory ( client_conn , server_conn )
perform the tls handshake between two connection instances connected to each other via memory bios .