client.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:bt 作者: kracekumar 项目源码 文件源码
def __init__(self, torrent, savedir):
        self.torrent = torrent
        self.total_pieces = len(self.torrent.info.pieces)
        self.peers = {}
        # TODO: Come up with different data structure to store
        # states of different pieces and blocks. Probably dict or set?
        self.pending_blocks = []
        self.ongoing_pieces = []
        self.have_pieces = []
        self.missing_pieces = self.make_pieces()
        self.max_pending_time = 300 * 1000 # Seconds
        self.progress_bar = Bar('Downloading', max=self.total_pieces)
        if savedir == '.':
            name = self.torrent.name
        else:
            name = os.path.join(savedir, self.torrent.name)
        self.fd = os.open(name, os.O_RDWR | os.O_CREAT)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号