curl-and-python

Re: Aborting HTTPPOST operation

From: Michael Wood <esiotrot_at_gmail.com>
Date: Wed, 13 Apr 2011 09:27:21 +0200

On 13 April 2011 09:15, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Tue, 12 Apr 2011, Abe Music wrote:
>
>> When the exception occurs it's a great thing because I can catch it and
>> update the GUI appropriately. The problem is that sometimes an exception is
>> not thrown and the progress function continuously reports the same number of
>> bytes have been uploaded and it never increases. I would expect this
>> functionality in the event no exceptions were being reported, but it's an
>> absolute must that I can detect any anomalies during the upload and let the
>> user know what's happening.
>
> Welcome to TCP. This is a transfer protocol that was designed to handle that
> nothing occurs and even that connections are teared down and put back up
> again without that fact causes a problem.
>
> There is only a set of things that cause the connection to actually fail
> hard, while many situations are not considered fatal problems.
>
> You may want to look into forcing TCP keepalive on the connection, and then
> with a higher frequency than the 2 hours most systems offer by default.
>
>> To workaround this I tried to keep tabs on how many times the progress
>> function reports the same number of uploaded bytes and, after an arbitrary
>> threshold, I let the user know and close the application (to stop the
>> thread.) I would love to be able to stop the thread and start again later,
>> but it appears that the perform() method has the scope in my thread and I
>> can't make it stop.
>
> Of course you can use all sorts of metrics in your own code to decide when
> you think the transfer has stalled. As it is just stalled. When you put
> everything back and plug in again, the transfer is capable of continuing.
>
> And you're free to tell libcurl to stop the transfer when you think it
> should!

I believe libcurl also has a low speed limit option that might help.
i.e. it tells libcurl to abort the connection if too few bytes get
transferred per second which might indicate that the connection has
stalled.

-- 
Michael Wood <esiotrot_at_gmail.com>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2011-04-13