Changed sleep() call for Fixing Delay.

- Also Tweaked Torrent Metadata Status Logic a bit.
This commit is contained in:
jaskaranSM 2019-10-19 16:44:26 +05:30
parent fa664e6663
commit b7e65d9c9c
3 changed files with 10 additions and 8 deletions

3
.gitignore vendored
View File

@ -11,4 +11,5 @@ data*
.idea
*.json
*.pickle
authorized_chats.txt
authorized_chats.txt
log.txt

View File

@ -41,23 +41,22 @@ class DownloadHelper:
should_update = True
if self.__is_torrent:
# Waiting for the actual gid
new_gid = None
while new_gid is None:
download = self.__get_download()
download = self.__get_download()
while download.is_complete != True: # Check every few seconds
download = self.__get_download()
if download.has_failed:
self.__listener.onDownloadError(download.error_message, status_list, index)
return
if download.is_paused:
self.__listener.onDownloadError("Download cancelled manually by user", status_list, index)
return
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
if should_update:
try:
self.__listener.onDownloadProgress(get_download_status_list(), index)
except KillThreadException:
should_update = False
# Check every few seconds
new_gid = self.__get_followed_download_gid()
sleep(DOWNLOAD_STATUS_UPDATE_INTERVAL)
new_gid = self.__get_followed_download_gid()
with download_dict_lock:
download_dict[self.__listener.message.message_id] = DownloadStatus(new_gid,
self.__listener.message.message_id)

View File

@ -4,6 +4,7 @@ from bot import download_dict, aria2, dispatcher, download_dict_lock, DOWNLOAD_D
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.ext_utils.fs_utils import clean_download
from bot.helper.telegram_helper.bot_commands import BotCommands
from time import sleep
@run_async
def cancel_mirror(update: Update, context):
@ -28,6 +29,7 @@ def cancel_mirror(update: Update, context):
upload_helper = download_dict[mirror_message.message_id].upload_helper
if upload_helper is not None:
upload_helper.cancel()
sleep(1) #Wait a Second For Aria2 To free Resources.
clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/')
@ -35,7 +37,7 @@ def cancel_mirror(update: Update, context):
def cancel_all(update, context):
aria2.pause_all(True)
sendMessage('Cancelled all downloads!', context, update)
sleep(1) #Wait a Second For Aria2 To free Resources.
clean_download(DOWNLOAD_DIR)