From 03f633e5ab5d7690ee3ef64c89ba54eeb080844f Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 12 Dec 2023 20:49:54 +0200 Subject: [PATCH] Update the handler to close the connection if empty data. --- notification_producer/producer_client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/notification_producer/producer_client.py b/notification_producer/producer_client.py index ae4e234..559046b 100644 --- a/notification_producer/producer_client.py +++ b/notification_producer/producer_client.py @@ -58,10 +58,16 @@ class ProducerClient: message = input('message: ') await self.send_notification(title, message) + if title == '' and message == '': + self.console.print(f"[yellow b][INFO][/] Finished.") + self.console.print("[green]bye[/]") + break + except asyncio.CancelledError: pass except KeyboardInterrupt: print("\nbye") + await self.send_notification('', '') sys.exit(0) finally: self.writer.close()