diff --git a/hbmqtt/mqtt/protocol/handler.py b/hbmqtt/mqtt/protocol/handler.py index d1c9fc3..3b6c496 100644 --- a/hbmqtt/mqtt/protocol/handler.py +++ b/hbmqtt/mqtt/protocol/handler.py @@ -432,7 +432,7 @@ async def _reader_loop(self): async def _send_packet(self, packet): try: - with (await self._write_lock): + async with self._write_lock: await packet.to_stream(self.writer) if self._keepalive_task: self._keepalive_task.cancel()