cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: progressfunction called too much

From: Linos <info_at_linos.es>
Date: Fri, 31 May 2013 09:46:21 +0200

On 31/05/13 03:30, NSRT Mail account. wrote:
> I notice that in libcurl C that if I set some upload rate limits, and upload a
> sizable file, the progress fuction is also called way too often.
> -Nach
>
> --------------------------------------------------------------------------------
> *From:* Linos <info_at_linos.es>
> *To:* curl-library_at_cool.haxx.se
> *Sent:* Thursday, May 30, 2013 7:33 PM
> *Subject:* progressfunction called too much
>
> Hello,
> i am using pycurl in a small script to download coursera videos, it's working
> fine but the callback i installed to display a progress bar in console it's
> called 22188558 times in 70 seconds of execution, it hangs 1 core of the machine
> all the time.
>
> given the documentation states should be called "roughly once per second or
> sooner" this seems too much for me, i am using this code to use it, it's python
> but i think it's pretty readable.
>
> curl = pycurl.Curl()
> curl.setopt(curl.URL, url)
>
> if rate_limit is not None:
> curl.setopt(curl.MAX_RECV_SPEED_LARGE, rate_limit)
>
> file_store = open(filename, "wb")
> curl.setopt(curl.WRITEDATA, file_store)
>
> curl.setopt(curl.NOPROGRESS, 0)
> curl.setopt(curl.PROGRESSFUNCTION, curl_progress)
>
> curl.setopt(curl.FOLLOWLOCATION, 1)
>
> #cookies
> curl.setopt(curl.COOKIEJAR, cookies_filename)
> curl.setopt(curl.COOKIEFILE, cookies_filename)
>
> try:
> curl.perform()
> except:
> import traceback
> my_logger.error(u"Error downloading file: %s" % traceback.format_exc())
>
> #cleaning
> curl.close()
> file_store.close()
>
> no matter that i define curl_progress as:
>
> def curl_progress(dl_total, dl_now, ul_total, ul_now):
> return 0
>
> it's called so much times that hangs 1 cpu core anyway.
>
> Maybe i am missing some option? Thanks.
>
>
> Regards,
> Miguel Angel.
> -------------------------------------------------------------------

I can confirm this problem completely disappear if i don't rate limit the download.

Regards,
Miguel Angel.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-05-31