Ensure the handshake really completes before returning from _loopback
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index 0d7df16..94ff66c 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -100,12 +100,15 @@
client = Connection(Context(TLSv1_METHOD), client)
client.set_connect_state()
- for i in range(3):
- for conn in [client, server]:
+ conns = [client, server]
+ while conns:
+ for conn in conns:
try:
conn.do_handshake()
except WantReadError:
pass
+ else:
+ conns.remove(conn)
server.setblocking(True)
client.setblocking(True)