Skip to content

aclose

Close the subscription connection if it is open. Await this method when cleaning up a subscription outside an async with block.

Close the subscription connection, if it is open.

Example
stream = client.subscribe([{"event": "pane.output"}])
async with stream:
    print(stream.ack)
await stream.aclose()
Source code in src/herdr_client/async_client/client.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
async def aclose(self) -> None:
    """Close the subscription connection, if it is open.

    Example:
        ```python
        stream = client.subscribe([{"event": "pane.output"}])
        async with stream:
            print(stream.ack)
        await stream.aclose()
        ```
    """
    writer, self._writer = self._writer, None
    self._reader = None
    if writer is not None:
        await close_writer(writer)