From 16bea42d2d17e2547204febba5fbcd0c514c8251 Mon Sep 17 00:00:00 2001 From: Dawn India Date: Fri, 11 Oct 2024 20:27:43 +0530 Subject: [PATCH] Minor fix N/A Signed-off-by: Dawn India --- bot/helper/ext_utils/bot_utils.py | 17 ++++++++--------- bot/helper/listeners/qbit_listener.py | 6 +++--- bot/helper/listeners/task_listener.py | 8 ++++---- .../task_utils/status_utils/meta_status.py | 1 - .../task_utils/status_utils/rclone_status.py | 1 - bot/helper/telegram_helper/message_utils.py | 18 ++++++++++-------- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/bot/helper/ext_utils/bot_utils.py b/bot/helper/ext_utils/bot_utils.py index f27f0475d8b0..df5b0e5a74bd 100644 --- a/bot/helper/ext_utils/bot_utils.py +++ b/bot/helper/ext_utils/bot_utils.py @@ -31,17 +31,16 @@ from ..telegram_helper.bot_commands import BotCommands COMMAND_USAGE = {} -max_workers = min( - 10000, - ( - cpu_count() - or 0 - ) + 4 -) -THREAD_POOL = ThreadPoolExecutor(max_workers=max_workers) +THREAD_POOL = ThreadPoolExecutor(max_workers=4000) class SetInterval: - def __init__(self, interval, action, *args, **kwargs): + def __init__( + self, + interval, + action, + *args, + **kwargs + ): self.interval = interval self.action = action self.task = bot_loop.create_task( diff --git a/bot/helper/listeners/qbit_listener.py b/bot/helper/listeners/qbit_listener.py index 7a5c7fcc2212..8669e6fc5fcb 100644 --- a/bot/helper/listeners/qbit_listener.py +++ b/bot/helper/listeners/qbit_listener.py @@ -102,7 +102,7 @@ async def _stop_duplicate(tor): button ) = await stop_duplicate_check(task.listener) # type: ignore if msg: - await _on_download_error( + _on_download_error( msg, tor, button @@ -120,7 +120,7 @@ async def _size_checked(tor): LOGGER.info( f"qBit Limit Exceeded: {task.listener.name} | {get_readable_file_size(task.listener.size)}" # type: ignore ) - qmsg = await _on_download_error( + qmsg = _on_download_error( limit_exceeded, tor ) @@ -157,7 +157,7 @@ async def _avg_speed_check(tor): LOGGER.info( f"Task is slower than minimum download speed: {task.listener.name} | {get_readable_file_size(dl_speed)}ps" ) - qmsg = await _on_download_error( + qmsg = _on_download_error( min_speed, tor ) diff --git a/bot/helper/listeners/task_listener.py b/bot/helper/listeners/task_listener.py index 467e737703a9..1ae1b120233a 100644 --- a/bot/helper/listeners/task_listener.py +++ b/bot/helper/listeners/task_listener.py @@ -371,14 +371,14 @@ async def on_download_complete(self): self, tg, gid, - "up", + "up" ) await gather( update_status_message(self.message.chat.id), # type: ignore tg.upload( unwanted_files, files_to_delete - ), + ) ) elif is_gdrive_id(self.up_dest): # type: ignore LOGGER.info(f"Gdrive Upload Name: {self.name}") @@ -391,7 +391,7 @@ async def on_download_complete(self): self, drive, gid, - "up", + "up" ) await gather( update_status_message(self.message.chat.id), # type: ignore @@ -399,7 +399,7 @@ async def on_download_complete(self): drive.upload, unwanted_files, files_to_delete - ), + ) ) else: LOGGER.info(f"Rclone Upload Name: {self.name}") diff --git a/bot/helper/task_utils/status_utils/meta_status.py b/bot/helper/task_utils/status_utils/meta_status.py index dc79b7e6692a..5e3803f6f67c 100644 --- a/bot/helper/task_utils/status_utils/meta_status.py +++ b/bot/helper/task_utils/status_utils/meta_status.py @@ -4,7 +4,6 @@ ) from ...ext_utils.status_utils import ( get_readable_file_size, - get_readable_time, MirrorStatus ) from subprocess import run as frun diff --git a/bot/helper/task_utils/status_utils/rclone_status.py b/bot/helper/task_utils/status_utils/rclone_status.py index 3f801ffcae25..f8d666fe1ca6 100644 --- a/bot/helper/task_utils/status_utils/rclone_status.py +++ b/bot/helper/task_utils/status_utils/rclone_status.py @@ -2,7 +2,6 @@ from subprocess import run as rrun - class RcloneStatus: def __init__( self, diff --git a/bot/helper/telegram_helper/message_utils.py b/bot/helper/telegram_helper/message_utils.py index a1fbc4474c52..1b14f83cb9a7 100644 --- a/bot/helper/telegram_helper/message_utils.py +++ b/bot/helper/telegram_helper/message_utils.py @@ -276,7 +276,10 @@ async def update_status_message(sid, force=False): status = status_dict[sid]["status"] is_user = status_dict[sid]["is_user"] page_step = status_dict[sid]["page_step"] - text, buttons = await get_readable_message( + ( + text, + buttons + ) = await get_readable_message( sid, is_user, page_no, @@ -303,9 +306,7 @@ async def update_status_message(sid, force=False): obj.cancel() del intervals["status"][sid] else: - LOGGER.error( - f"Status with id: {sid} haven't been updated. Error: {message}" - ) + LOGGER.error(f"Status with id: {sid} haven't been updated. Error: {message}") return status_dict[sid]["message"].text = text status_dict[sid]["time"] = time() @@ -321,7 +322,10 @@ async def send_status_message(msg, user_id=0): page_no = status_dict[sid]["page_no"] status = status_dict[sid]["status"] page_step = status_dict[sid]["page_step"] - text, buttons = await get_readable_message( + ( + text, + buttons + ) = await get_readable_message( sid, is_user, page_no, @@ -343,9 +347,7 @@ async def send_status_message(msg, user_id=0): block=False ) if isinstance(message, str): - LOGGER.error( - f"Status with id: {sid} haven't been sent. Error: {message}" - ) + LOGGER.error(f"Status with id: {sid} haven't been sent. Error: {message}") return message.text = text status_dict[sid].update({