Giter VIP home page Giter VIP logo

Comments (4)

ares333 avatar ares333 commented on June 19, 2024

根据Demo无法重现问题,检查$toolkit对象是否有问题。
demo地址:https://github.com/ares333/php-curl/blob/master/demo/running_info.php

from php-curl.

googles8 avatar googles8 commented on June 19, 2024

感谢题主及明回复。 我用running_info.php测试也可以正常。但我想要的是在下载时可以及时显示,于是我将demo/download.php中,$curl->onInfo = null; 换成了$curl->onInfo = array(
$toolkit,
'onInfo'
);
就报上面的错误。

经测试,不加上面的,而是将//$curl->onInfo = null; 注释掉,则可以显示。为什么会有这个不同?
而且发现,一个文件在下载的过程中,它的数值一直是0.
SPD:0KB DWN:0MB FNH:0 CACHE:0 RUN:1 ACTIVE:1 POOL:49 QUEUE:0 TASK:50 FAIL:0
只有该线程下载完成了,它的信息也会显示出数据来。
也就是说,它的信息是多线程下载中,某个线程下载完成后,它的信息。
这与想要的,在下载时,实时显示当时的速度等信息还是不同的。而一个大文件下载过程中,是需要实时知道已经下了多少,速度多少。
能针对这种显示吗?

SPD:0KB DWN:0MB FNH:0 CACHE:0 RUN:1 ACTIVE:1 POOL:49 QUEUE:0 TASK:50 FAIL:0

SPD:0KB DWN:0MB FNH:0 CACHE:0 RUN:1 ACTIVE:1 POOL:49 QUEUE:0 TASK:50 FAIL:0

SPD:200KB DWN:1MB FNH:7 CACHE:0 RUN:1 ACTIVE:1 POOL:42 QUEUE:0 TASK:50 FAIL:0

SPD:323KB DWN:2MB FNH:15 CACHE:0 RUN:1 ACTIVE:1 POOL:34 QUEUE:0 TASK:50 FAIL:0

SPD:407KB DWN:3MB FNH:23 CACHE:0 RUN:1 ACTIVE:1 POOL:26 QUEUE:0 TASK:50 FAIL:0

SPD:531KB DWN:4MB FNH:32 CACHE:0 RUN:1 ACTIVE:1 POOL:17 QUEUE:0 TASK:50 FAIL:0

SPD:614KB DWN:5MB FNH:41 CACHE:0 RUN:1 ACTIVE:1 POOL:8 QUEUE:0 TASK:50 FAIL:0

SPD:746KB DWN:6MB FNH:50 CACHE:0 RUN:0 ACTIVE:0 POOL:0 QUEUE:0 TASK:50 FAIL:0

from php-curl.

ares333 avatar ares333 commented on June 19, 2024
array(
    $toolkit,
    'onInfo'
);

$toolkit必须是Tookkit对象的实例,回调函数的具体用法看PHP手册:http://php.net/manual/en/function.call-user-func-array.php
//$curl->onInfo = null 注释掉显示运行状态是因为$curl对象由Toolkit初始化,默认设置了onInfo回调。

下载速度的计算规则是每隔一段时间根据已完成任务下载数据量和时间计算一次,所以要等有任务下载完毕。
实时计算需要考虑缓存等各种因素过于复杂没有实现,因为本类库的设计的目的处理是高并发大批量请求,所以认为没有必要去做这件事情(包括断点续传)。
如果有硬性需求可以通过继承等方式自行实现。

from php-curl.

googles8 avatar googles8 commented on June 19, 2024

感谢及时而有用的解答。终于明白了问题所在。
我用的$curl = (new Toolkit())->getCurl();因此,在调用时$toolkit的确不是实例。从而导致出错。
你这关注的果然是多线程的完成情况,在处理是高并发大批量请求时,这种考虑是对的。我开始是以为你这个也带了这种功 能。看了你的说明后,自己已经成功实现了下载大文件的实时进度显示。再次感谢

from php-curl.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.