curl-and-python

Re: CURLE_OPERATION_TIMEDOUT while connecting.

From: Evgeny Turnaev <turnaev.e_at_gmail.com>
Date: Fri, 4 May 2012 12:21:01 +0400

2012/5/4 Daniel Stenberg <daniel_at_haxx.se>:
> On Fri, 4 May 2012, Evgeny Turnaev wrote:
>
>>> Are you trying to say setting pycurl.TIMEOUT as 0 your code run smoothly
>>> but it gives time out error when you set it to 5?
>>
>>
>> No when i dont set timeout at all.
>
>
> Setting TIMEOUT to 0 is the same as not setting a timeout.
>
>
>> Obviously a newly added curl with timeouts set to 1 and 5 seconds cant
>> expire just after adding curl.
>>
>> Daniel, no i dont think this is dns resolving error because debug show
>> newly added curl timed outed in a 1 ms (in fact earlier as python logging is
>> slow as hell).
>
>
> There's an internal timeout set to 1ms when you add a new handle, yes.
> That's because libcurl wants to to call it again immediately after you've
> added a handle so that it can "drive it" as far as possible and it can't (or
> rather it won't) do that already in the add handle function function.
>
> But really, let me emphasize what I started out this thread by saying:
>
> You really want to use the libcurl timeout callback (CURLMOPT_TIMERFUNCTION)
> when you use the multi_socket API. If you don't, you really need to know
> what you're doing and how libcurl works to be able to reach the same
> functionality anyway and I don't mean to be rude but you really don't give
> the impression of having that control or knowledge.
>
> --

Ok i added timer function to snippet and calling multi.socket_action
when timer expires. Though i dont know should i call
multi.socket_action when timer expires even when there is no curls
left in multi ?

code: http://pastebin.com/RaKviAnE
output: http://pastebin.com/EdL4Sf9m

Result is the same: newly added curl get expired right after
add_handle. Regarding to 1ms timeout (to call socket_action after
add_handle): i added time.sleep(0.1) just after add_handle and it
worked ok.

And also: still this code snippet works ok without
setopt(pycurl.CONNECTTIMEOUT, 1) so i continue insisting there is
something with CONNECTTIMEOUT.

>
>  / daniel.haxx.se
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>

-- 
--------------------------------------------
Турнаев Евгений Викторович
+7 906 875 09 43
--------------------------------------------
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2012-05-04