Posts Tagged ‘python’

yum-fastestmirror – excluding mirrors in 1.1.16

Wednesday, April 8th, 2009

In yum-fastestmirror-1.1.16-13.el5.centos, I discovered a bug involving the exclude option in fastestmirror.conf . If you exclude two mirrors that are adjacent in the mirror repository array used by fastestmirror.py to search for excluded mirrors, the second one will not be removed from the list of possible mirrors.

The reason this occurs is because the for loop which iterates through the array skips the next value after an entry is removed from the array. I was able to fix it by changing line 195 from:

for mirror in repomirrors[str(repo)]:

to

for mirror in repomirrors[str(repo)][:]:

Now it uses a copy of the array to search, and can delete the entry from the original array without effecting the next value in the for loop.

It appears that this bug has been resolved in yum-utils-1.1.18 and higher, by using the filter command to go through each mirror and test it against the exclude list. I’m learning all sorts of neat python tricks today!