engine.py 文件源码

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

项目:solaris-ips 作者: oracle 项目源码 文件源码
def __check_for_stalls(self):
                """In some situations, libcurl can get itself
                tied in a knot, and fail to make progress.  Check that the
                active handles are making progress.  If none of the active
                handles have downloaded any content for the timeout period,
                reset the transport and generate exceptions for the failed
                requests."""

                timeout = global_settings.PKG_CLIENT_LOWSPEED_TIMEOUT
                if timeout == 0:
                        return
                current_time = time.time()
                time_list = []
                size_list = []
                failures = []
                q_hdls = [
                    hdl for hdl in self.__chandles
                    if hdl not in self.__freehandles
                ]

                # time.time() is based upon system clock.  Check that
                # our time hasn't been set backwards.  If time is set forward,
                # we'll have to expire the handles.  There's no way to detect
                # this until python properly implements gethrtime().  Solaris
                # implementations of time.clock() appear broken.

                for h in q_hdls:
                        time_elapsed = current_time - h.starttime
                        if time_elapsed < 0:
                                h.starttime = current_time
                                time_elapsed = 0
                        size_xfrd = h.getinfo(pycurl.SIZE_DOWNLOAD) + \
                            h.getinfo(pycurl.SIZE_UPLOAD)
                        time_list.append(time_elapsed)
                        size_list.append(size_xfrd)

                # If timeout is smaller than smallest elapsed time,
                # and no data has been transferred, abort.
                if timeout < min(time_list) and max(size_list) == 0:
                        for h in q_hdls:
                                url = h.url
                                uuid = h.uuid
                                urlstem = h.repourl
                                ex = tx.TransportStallError(url,
                                    repourl=urlstem, uuid=uuid)

                                self.__mhandle.remove_handle(h)
                                self.__teardown_handle(h)
                                self.__freehandles.append(h)

                                failures.append(ex)

                self.__failures.extend(failures)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号