diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py
index df5b0e5a74bd..65e7d9b6d328 100644
--- a/bot/helper/ext_utils/bot_utils.py
+++ b/bot/helper/ext_utils/bot_utils.py
@@ -31,7 +31,16 @@
from ..telegram_helper.bot_commands import BotCommands
COMMAND_USAGE = {}
-THREAD_POOL = ThreadPoolExecutor(max_workers=4000)
+
+max_workers = min(
+ 10000,
+ (
+ cpu_count()
+ or 0
+ ) + 4
+)
+THREAD_POOL = ThreadPoolExecutor(max_workers=max_workers)
+
class SetInterval:
def __init__(
diff --git a/bot/helper/listeners/task_listener.py b/bot/helper/listeners/task_listener.py
index 1ae1b120233a..1ad7cb9bbd18 100644
--- a/bot/helper/listeners/task_listener.py
+++ b/bot/helper/listeners/task_listener.py
@@ -720,7 +720,7 @@ async def on_download_error(self, error, button=None):
if self.mid in task_dict:
del task_dict[self.mid]
count = len(task_dict)
- await self.remove_from_same_dir()
+ await self.remove_from_same_dir()
msg = f"Sorry {self.tag}!\nYour download has been stopped."
msg += f"\n\nReason
: {escape(str(error))}"
msg += f"\nPast
: {get_readable_time(time() - self.time)}"
diff --git a/bot/helper/telegram_helper/message_utils.py b/bot/helper/telegram_helper/message_utils.py
index 869703794c53..2ef3f6d42d14 100644
--- a/bot/helper/telegram_helper/message_utils.py
+++ b/bot/helper/telegram_helper/message_utils.py
@@ -1,7 +1,4 @@
-from asyncio import (
- sleep,
- create_task,
-)
+from asyncio import sleep
from re import match as re_match
from time import time
from datetime import (
@@ -22,6 +19,7 @@
from bot import (
LOGGER,
bot,
+ bot_loop,
bot_name,
cached_dict,
config_dict,
@@ -141,7 +139,7 @@ async def auto_delete():
await delete_message(cmd_message)
if bot_message is not None:
await delete_message(bot_message)
- create_task(auto_delete())
+ bot_loop.create_task(auto_delete())
async def delete_links(message):