From 4dbe60a9f71791b17e7af851de50ad6fa71f2e84 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:23:59 -0400 Subject: [PATCH] Guard to make sure we can't send data while the transport is closing --- bellows/ash.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bellows/ash.py b/bellows/ash.py index 06156eb0..2f9c8212 100644 --- a/bellows/ash.py +++ b/bellows/ash.py @@ -579,6 +579,9 @@ def _write_frame( prefix: tuple[Reserved] = (), suffix: tuple[Reserved] = (Reserved.FLAG,), ) -> None: + if self._transport is None or self._transport.is_closing(): + raise NcpFailure("Transport is closed, cannot send frame") + if _LOGGER.isEnabledFor(logging.DEBUG): prefix_str = "".join([f"{r.name} + " for r in prefix]) suffix_str = "".join([f" + {r.name}" for r in suffix])