From 86bc76d49522b762477e01a4d9db57470ce4da01 Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Tue, 1 Aug 2017 19:31:24 +0200 Subject: [PATCH] Use async connect9) instead of feeding loop --- secret_handshake/network.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/secret_handshake/network.py b/secret_handshake/network.py index 92e5f82..c5fa649 100644 --- a/secret_handshake/network.py +++ b/secret_handshake/network.py @@ -109,9 +109,9 @@ class SHSClient(SHSSocket): if not self.crypto.verify_server_accept(data): raise SHSClientException('Server accept is not valid') - def connect(self): - reader, writer = self.loop.run_until_complete(open_connection(self.host, self.port, loop=self.loop)) - self.loop.run_until_complete(self._handshake(reader, writer)) + async def connect(self): + reader, writer = await open_connection(self.host, self.port, loop=self.loop) + await self._handshake(reader, writer) keys = self.crypto.get_box_keys() self.crypto.clean() @@ -119,4 +119,4 @@ class SHSClient(SHSSocket): self.read_stream, self.write_stream = get_stream_pair(reader, writer, **keys) self.writer = writer if self._on_connect: - ensure_future(self._on_connect(), loop=self.loop) + await self._on_connect()