예제 #1
0
def being_download(hash_sign):
    # todo:兼容其他是否下載的驗證方式
    redis_queue = RedisMsgQueue()
    all_files_json = redis_queue.set_get_all(
        consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME)
    for file_str in all_files_json:
        file_json = from_string_to_json(file_str)
        if hash_sign == file_json['hash_sign']:
            return True
    return False
예제 #2
0
def monitor_download_status():
    """
    1.读取内存中的即下载文件,以及总大小
    2.读取这些文件目前大小,以及间隔时间的下载速度(每秒讀取一次)
    :return:
    """
    # todo:性能优化,通用下载器的文件下载监控方式
    redis_queue = RedisMsgQueue()
    while True:
        all_files_old_json = redis_queue.set_get_all(
            consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME)
        for single_file_json in all_files_old_json:
            single_file_json['now_size'] = '读取文件大小'
        time.sleep(3)
        all_files_new_json = redis_queue.set_get_all(
            consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME)
        for single_file_json in all_files_new_json:
            single_file_json['now_size'] = '读取文件大小'
            single_file_json['download_speed'] = ('now_size' - 'now_size') / 3
            # 修改最新值,重新一个个放入内存中
            if 'download_speed' <= 0:
                '塞入队列重新下载'
    pass