From 5602962d50d8df922d1fa6523e99d9bc2dcfd915 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 3 Oct 2023 04:54:47 +0200 Subject: [PATCH 1/4] Add timeout to sub process --- discord_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord_bot.py b/discord_bot.py index f968c39..dbb7e90 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -218,7 +218,7 @@ async def background_task(): stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) - stdout, stderr = await proc.communicate() + stdout, stderr = await asyncio.wait_for(proc.communicate(), 30) output = stdout.decode() if not output: continue From 03d95713b4540a9cea016b9d597e54dfea8e3f11 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 3 Oct 2023 23:47:38 +0200 Subject: [PATCH 2/4] Update discord_bot.py --- discord_bot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/discord_bot.py b/discord_bot.py index dbb7e90..170ac61 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -218,7 +218,10 @@ async def background_task(): stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) - stdout, stderr = await asyncio.wait_for(proc.communicate(), 30) + try: + stdout, stderr = await asyncio.wait_for(proc.communicate(), 2) + except TimeoutError: + continue output = stdout.decode() if not output: continue From 60acac1177ae20994ec05cde8a49694016ea27ca Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 3 Oct 2023 23:54:56 +0200 Subject: [PATCH 3/4] Update discord_bot.py --- discord_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord_bot.py b/discord_bot.py index 170ac61..b1ea71b 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -219,7 +219,7 @@ async def background_task(): stderr=asyncio.subprocess.PIPE) try: - stdout, stderr = await asyncio.wait_for(proc.communicate(), 2) + stdout, stderr = await asyncio.wait_for(proc.communicate(), 30) except TimeoutError: continue output = stdout.decode() From 74ca3764f5a18bfc6caee653baad8caf4fc531d6 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 16 Feb 2024 03:01:10 +0100 Subject: [PATCH 4/4] Update discord_bot.py --- discord_bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord_bot.py b/discord_bot.py index b1ea71b..9853b3f 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -221,6 +221,7 @@ async def background_task(): try: stdout, stderr = await asyncio.wait_for(proc.communicate(), 30) except TimeoutError: + proc.terminate() continue output = stdout.decode() if not output: