This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import threading | |
import requests | |
import tqdm | |
class Downloader(object): | |
def __init__(self, url, name="notitle", worker_num=8, resume=True): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
redis 分布式悲观锁,需要解决以下几个问题 | |
1、A获取锁后崩溃,需要能将锁释放 | |
2、A获取锁后处理时间过长,导致锁过期,被B获取,A处理完后错误的将B锁释放 | |
redis.Redis()会有些问题,连接最好使用redis.StrictRedis() | |
""" | |
import math |
NewerOlder