curl-and-python
Re: CURLE_OPERATION_TIMEDOUT while connecting.
Date: Sun, 29 Apr 2012 21:00:15 +0400
Hello Daniel.
I as wrote earlier i am going to use socket_all() and the thing that
bothers me - is socket_all() going to be removed in near future?
Another option for me would be - to set some high timeouts that i
know is not going to be reached (i will remove handle earlier). But
the thing that bothers me in this solution is an issue from previous
letter: after 130 seconds of idle i added fresh new handle to multi
and info_read said that it is timed out. Could you please explain me
this behavior - is it an error in my code?
2012/4/27 Evgeny Turnaev <turnaev.e_at_gmail.com>:
> Here is an example code:
> http://pastebin.com/bEK8Twqe
>
> and its debug output:
> http://pastebin.com/6uyUQ50k
>
> I did not managed to reproduce issue with just one curl so i made a
> copy of what urls of real sources. I have replaced domain names and
> urls as it contains key (thought not production keys).
> So from the log i see that after 130 sec of waiting when i create curl and call
> multi.socket_action(pycurl.SOCKET_TIMEOUT, 0)
> process_curl_complete_handles()
>
> curl says that my newly created curl is timeout outed.
> whats wrong?
>
> As i work around i am planning to remove
> setopt(pycurl.CONNECTTIMEOUT, 1)
> setopt(pycurl.TIMEOUT, 5)
> and call socket_all() instead of socket_action(pycurl.SOCKET_TIMEOUT, 0)
>
> If anyone need more debug info - i can modify example code in any way
> or send it with original urls in private email.
>
> 2012/4/26 Utsav Sabharwal <tashywashysachy_at_live.in>:
>> @Evgeny: Can you please share the source code?
>>
>>
>>> Date: Thu, 26 Apr 2012 19:44:16 +0200
>>> From: daniel_at_haxx.se
>>> To: curl-and-python_at_cool.haxx.se
>>> Subject: Re: CURLE_OPERATION_TIMEDOUT while connecting.
>>> CC: curl-library_at_cool.haxx.se
>>
>>>
>>> On Thu, 26 Apr 2012, Evgeny Turnaev wrote:
>>>
>>> > I am trying to make use of pycurl with multi interface + pyev and there
>>> > are some issues i dont understand from docs:
>>>
>>> And with multi interface you mean the multi_socket API as I understand it.
>>>
>>> > I am not planning to use curl timeout system but to use libev timers and
>>> > manually remove_handle from multi when timeout happens.
>>>
>>> Sorry, but I don't understand how. What timeout values will you use if you
>>> don't use the ones libcurl provide? Also, I really strongly advice you to
>>> use
>>> the timeout callback to get the timeout info. I think you'll see that it
>>> is
>>> the smoothest path forward when using the multi_socket API.
>>>
>
> I use libev to fetch non-http sources and also to manage my own
> application timeouts with pyev.Timer
> so it is more convenient to me to use pyev timers for curl. Sorry, i
> don't see any decent way to make curl timeouts work together with
> libev loop.
> Besides I've been told by few people that used curl before that curl
> did not managed timeouts properly.
> I also found in tornado (http://www.tornadoweb.org/) sources comments
> that curl sometimes forgets timeouts and so tornado people make they
> own checking of timeouts periodically.
>
>
>>> > 1) I create curl and and handle to multi with multi.add_handle(c) but
>>> > if dont call multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) nothing
>>> > fetches.
>>>
>>> Exactly. Because you ignore libcurl's timeouts you don't call libcurl
>>> properly
>>> on the timeout that it has set, so you do it blindly instead and happens
>>> to
>>> get the same effect.
>>>
>>> > But there is also multi.socket_all() witch is seems to be doing the
>>> > same?
>>>
>>> It doesn't do the same, but in this case the end result will be the same.
>>>
>>> > Is there any difference in calling
>>> > multi.socket_action(pycurl.SOCKET_TIMEOUT, 0) or multi.socket_all()
>>> > What is cheaper?
>>>
>>> The first is MUCH cheaper, as the second will act on every single handle
>>> that
>>> you have added and the first will only act on the handles that actually
>>> have
>>> timed out. curl_multi_socket_all() is also deprecated so you really
>>> shouldn't
>>> use it.
>>>
>
> Thats sad. Do curl sets some kind of default timeouts? what will
> happen if dont call
> setopt(pycurl.TIMEOUT, 5)
> and then call
> socket_action(pycurl.SOCKET_TIMEOUT, 0)
> will i ever receive timeout?
>
>>> > 2) the main question: when a keepalive socket timeout outed and curl
>>> > thinks
>>> > connection is dead and tells so via error list of multi.info_read() do i
>>> > have to manually start another Curl() instance in order to fetch url
>>> > finally? (i thought curl will just ask for another socket)
>>>
>>> A timeout error is an error that will stop that particular transfer. If
>>> you
>>> want to start another transfer on that handle, you need to remove it and
>>> re-add it to the multi-handle.
>>>
>>> > Does creating pool of curls will somehow help in such situation?
>>>
>>> I'm not following what you're asking here so I don't know.
>>>
>>> > CURLE_OPERATION_TIMEDOUT means connect timeout or fetch timeout or both?
>>> > Can
>>> > it be related to any other?
>>>
>>> It means it reached a timeout value internally. I think the error code is
>>> restricted to only be returned if one of the user provided limits are
>>> reached.
>>>
>>> > Why Connection #0 gets closed 2 times?
>>>
>>> I don't know, I don't think there was enough details for me to figure out
>>> what
>>> was really going on there.
>>>
>>> --
>>>
>>> / daniel.haxx.se
>>> _______________________________________________
>>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>>
>> _______________________________________________
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>>
>
>
>
> --
> --------------------------------------------
> Турнаев Евгений Викторович
> +7 906 875 09 43
> --------------------------------------------
-- -------------------------------------------- Турнаев Евгений Викторович +7 906 875 09 43 -------------------------------------------- _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-pythonReceived on 2012-04-29