[Yum-devel] urlgrabber socket timeouts

Ryan Tomayko rtomayko at naeblis.cx
Wed Sep 29 13:51:12 UTC 2004


If we wanted to get crufty and support < 2.2 we could do something like:

import socket
if hasattr(socket, 'setdefaulttimeout'):
   set_timeout = socket.setdefaulttimeout
else:
   try:
     import timeoutsocket
     set_timeout = timeoutsocket.setDefaultSocketTimeout
   except ImportError:
     # no possible way of supporting timeout
     set_timeout = None

Now we can call set_timeout to support both Python 2.3's native support 
or, failing that, the timeoutsocket hack for < 2.3.

http://www.steffensiebert.de/soft/python/timeoutsocket.py

Not sure all this is worth it but I thought I'd throw it out there.

Ryan

On Sep 29, 2004, at 1:44 AM, seth vidal wrote:
>
>> You're not in left field at all.  The only issue is that this is only
>> available in 2.3.  In previous versions, you'd need to include a third
>> party module.
>
> Works for me - let's do a check for the function, if it's not there,
> then it doesn't get set, sucks to be running python 2.2. :)
>
>> I agree that this is a good way to go.  It doesn't completely solve
>> timeout problems though because tcp timeouts won't always save you
>> from a stupid/slow server.  A tcp timeout happens when one side sends
>> a request but doesn't get an acknowledgement.  It's quite possible
>> (and common in ssh or imap connections) to simply have no requests
>> made for a very long time.  In that case, you'd also need higher-level
>> timeouts, which I was looking into a couple weeks ago before I got
>> swamped in work.
>
> My tests:
>
> set the timeout to 30s
> start downloading something big
> login to server, set -j DROP on the iptables from the downloading host
> wait 30s, it times out
> restart the download
> login to server, set -j DROP on the iptables from the downloading host
> wait 20s
> unset the -j DROP
> it continues the download
> set the -j DROP
> wait 30s, it times out.
>
> Repeat the above with -j REJECT and turning off webserver.
> Now I know that's not all of the possible situations but I'd be willing
> to bet it's a good hunk of them.
>
>>
>> In short, I'd have no problem implementing this as an "only >=2.3"
>> feature.  However, we should probably be clear from the start that we
>> will eventually remove the checks, meaning: if you want to use new
>> urlgrabbers with old pythons for a long time, you should simply not
>> use this option.
>
> Fine by me.
>
> This would make a lot of people happy, I'm certain.
> -sv
>
>
> _______________________________________________
> Yum-devel mailing list
> Yum-devel at lists.linux.duke.edu
> https://lists.dulug.duke.edu/mailman/listinfo/yum-devel




More information about the Yum-devel mailing list