chunks.py 文件源码

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

项目:eos-data-distribution 作者: endlessm 项目源码 文件源码
def _do_express_interest(self, proxy, interface, interest):
        # XXX parse interest to see if we're requesting the first chunk
        self.first_segment = 0
        if (self._segments):
            self.current_segment = self.first_segment = self._segments.index(defaults.SegmentState.UNSENT) or 0
            logger.debug('STARTING AT %s', self.first_segment)
        self.interest = interest

        if self.filename:
            # did we already have an open file descriptor for this ? if yes,
            # we'd better close it here and reopen so that we're sure we get
            # a fresh fd.
            self.fd.close()

        # we prepare the file where we're going to write the data
        self.filename = '.edd-file-cache-' + interest.replace('/', '%')
        sendout_fd = open(self.filename, 'w+b')
        self.fd = open(self.filename, 'r+b')


        logger.debug('opened fd: %s', self.fd)

        fd_list = Gio.UnixFDList()
        fd_id = fd_list.append(sendout_fd.fileno())

        assert(self.filename)
        assert(self.fd)

        interface.connect('progress', self._on_progress)
        interface.call_request_interest(interest,
                                        GLib.Variant('h', fd_id),
                                        self.first_segment, fd_list=fd_list,
                                        callback=self._on_request_interest_complete,
                                        user_data=interest)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号