Add lock to RawConnection

To avoid `self.writer.drain()` is called in parallel.
Reference: https://bugs.python.org/issue29930
This commit is contained in:
mhchia
2019-08-20 17:09:38 +08:00
parent 5768daa9bf
commit 0b466ddc86
5 changed files with 37 additions and 27 deletions

View File

@ -21,8 +21,7 @@ class InsecureSession(BaseSession):
msg = make_exchange_message(self.local_private_key.get_public_key())
msg_bytes = msg.SerializeToString()
encoded_msg_bytes = encode_fixedint_prefixed(msg_bytes)
self.writer.write(encoded_msg_bytes)
await self.writer.drain()
await self.write(encoded_msg_bytes)
msg_bytes_other_side = await read_fixedint_prefixed(self.reader)
msg_other_side = plaintext_pb2.Exchange()