From 6724c408e8912ae67243ef5036f6054e3bcfd3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Thu, 7 Nov 2024 14:22:11 +0100 Subject: [PATCH 1/3] Close process in tools functions only if needed --- haffmpeg/tools.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/haffmpeg/tools.py b/haffmpeg/tools.py index 77aa101..414684e 100644 --- a/haffmpeg/tools.py +++ b/haffmpeg/tools.py @@ -52,7 +52,8 @@ async def get_image( return None finally: - await self.close(0) + if self.is_running: + await self.close(0) class FFVersion(HAFFmpeg): @@ -87,6 +88,7 @@ async def get_version(self, timeout: int = 15) -> Optional[str]: self.kill() finally: - await self.close(0) + if self.is_running: + await self.close(0) return None From 036f39abc40652259a48a10b8d494208e2ab6e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Thu, 7 Nov 2024 17:48:01 +0100 Subject: [PATCH 2/3] Revert "Close process in tools functions only if needed" This reverts commit 6724c408e8912ae67243ef5036f6054e3bcfd3e4. --- haffmpeg/tools.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/haffmpeg/tools.py b/haffmpeg/tools.py index 414684e..77aa101 100644 --- a/haffmpeg/tools.py +++ b/haffmpeg/tools.py @@ -52,8 +52,7 @@ async def get_image( return None finally: - if self.is_running: - await self.close(0) + await self.close(0) class FFVersion(HAFFmpeg): @@ -88,7 +87,6 @@ async def get_version(self, timeout: int = 15) -> Optional[str]: self.kill() finally: - if self.is_running: - await self.close(0) + await self.close(0) return None From 91b98d9508f9e2460993460ce75cadae21ce5725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Maggioni?= Date: Thu, 7 Nov 2024 17:48:56 +0100 Subject: [PATCH 3/3] Lower close() logging level to debug --- haffmpeg/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haffmpeg/core.py b/haffmpeg/core.py index d3ee93c..29d4488 100644 --- a/haffmpeg/core.py +++ b/haffmpeg/core.py @@ -145,7 +145,7 @@ async def open( async def close(self, timeout=5) -> None: """Stop a ffmpeg instance.""" if not self.is_running: - _LOGGER.warning("FFmpeg isn't running!") + _LOGGER.debug("FFmpeg isn't running!") return # Can't use communicate because we attach the output to a streamreader