From 5230a02f22ba60a4e42a1029349d87986a96c50c Mon Sep 17 00:00:00 2001 From: Moha Abdi <83307623+moha-abdi@users.noreply.github.com> Date: Sat, 4 May 2024 12:55:16 +0300 Subject: [PATCH] Fix: an exception when Client.stop_listening is called but the future is None --- pyromod/listen/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyromod/listen/client.py b/pyromod/listen/client.py index 726743f..4b265c4 100644 --- a/pyromod/listen/client.py +++ b/pyromod/listen/client.py @@ -193,7 +193,8 @@ async def stop_listening( async def stop_listener(self, listener: Listener): self.remove_listener(listener) - if listener.future.done(): + # we have to check if listener.future is not None [incase of Client.next_step_handler is used this will be None] + if listner.future is not None and listener.future.done(): return if callable(config.stopped_handler): @@ -204,7 +205,8 @@ async def stop_listener(self, listener: Listener): None, config.stopped_handler, None, listener ) elif config.throw_exceptions: - listener.future.set_exception(ListenerStopped()) + if listener.future is not None: + listener.future.set_exception(ListenerStopped()) @should_patch() def register_next_step_handler(