From ef7be652e87e4bee1943471b7d390d344544bbb3 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 7 Jun 2024 00:12:44 +0900 Subject: [PATCH] do not create sender at close (#208) --- fluent/asynchandler.py | 16 ---------------- fluent/handler.py | 4 +++- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/fluent/asynchandler.py b/fluent/asynchandler.py index 397608e..e3c3dc0 100644 --- a/fluent/asynchandler.py +++ b/fluent/asynchandler.py @@ -8,19 +8,3 @@ class FluentHandler(handler.FluentHandler): def getSenderClass(self): return asyncsender.FluentSender - - def close(self): - self.acquire() - try: - try: - self.sender.close() - finally: - super().close() - finally: - self.release() - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_val, exc_tb): - self.close() diff --git a/fluent/handler.py b/fluent/handler.py index 1018d69..8029604 100644 --- a/fluent/handler.py +++ b/fluent/handler.py @@ -264,7 +264,9 @@ def close(self): self.acquire() try: try: - self.sender.close() + if self._sender is not None: + self._sender.close() + self._sender = None finally: super().close() finally: