[Yum-devel] Yum timeout when running against Roxen webserver

Michael Stenner mstenner at linux.duke.edu
Tue Dec 5 23:53:02 UTC 2006


On Mon, Dec 04, 2006 at 01:55:42PM +0100, Anders Blomdell wrote:
> The problem is that urlgrabber tries to read more than the requested amount 
> of bytes, and therefore the connection times out. The following patch seems 
> to work:

Thanks for the debugging effort and patch.  I'm attaching the patch I
actually used (logically equivalent... simply style differences) in
case Jeremy wants to apply it elsewhere.

						-Michael

-- 
  Michael D. Stenner                            mstenner at ece.arizona.edu
  ECE Department and Optical Sciences Center                520-626-1619
  University of Arizona                                         ECE 524G
-------------- next part --------------
--- urlgrabber/grabber.py	22 Sep 2006 00:58:05 -0000	1.48
+++ urlgrabber/grabber.py	5 Dec 2006 23:48:51 -0000
@@ -1198,13 +1198,21 @@
         """dump the file to self.filename."""
         if self.append: new_fo = open(self.filename, 'ab')
         else: new_fo = open(self.filename, 'wb')
+        try:
+            # if we have a known range, only try to read that much.
+            (low, high) = self.opts.range
+            amount = high - low
+        except TypeError, ValueError:
+            amount = None
         bs = 1024*8
         size = 0
 
+        if amount is not None: bs = min(bs, amount - size)
         block = self.read(bs)
         size = size + len(block)
         while block:
             new_fo.write(block)
+            if amount is not None: bs = min(bs, amount - size)
             block = self.read(bs)
             size = size + len(block)
 


More information about the Yum-devel mailing list