From 04657ebb63a3fc5e31d59d8a944f79d6784be3b3 Mon Sep 17 00:00:00 2001 From: denpamusic Date: Wed, 30 Oct 2024 22:24:01 +0300 Subject: [PATCH] Update docs. --- docs/source/connecting.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/source/connecting.rst b/docs/source/connecting.rst index fcacaacb..a2103005 100644 --- a/docs/source/connecting.rst +++ b/docs/source/connecting.rst @@ -69,18 +69,22 @@ working with device classes and queues. async def main(): """Open a connection and request alerts.""" async with pyplumio.open_tcp_connection( - host="localhost", port=8899, protocol=pyplumio.DummyProtocol + host="localhost", port=8899, protocol=pyplumio.DummyProtocol() ) as connection: await connection.writer.write( requests.AlertsRequest(recipient=DeviceType.ECOMAX, start=0, count=5) ) while connection.connected: - if isinstance( - (frame := await connection.reader.read()), responses.AlertsResponse - ): - print(frame.data) - break + try: + if isinstance( + (frame := await connection.reader.read()), responses.AlertsResponse + ): + print(frame.data) + break + except pyplumio.ProtocolError: + # Skip protocol errors and read the next frame. + pass asyncio.run(main())