Prevent problem where repos at the 'bottom' of the dictionary were failing to sync during periods of extended load

This commit is contained in:
Anthony Brennan 2021-09-14 19:00:18 -04:00 committed by Mirror
parent 9c37804f75
commit 4f4f1a52af
1 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python2
import time, sys, os, errno, logging, signal, copy, select, socket, grp
import time, sys, os, errno, logging, signal, copy, select, socket, grp, random
daily = 86400
twice_daily = 86400 / 2
@ -634,7 +634,10 @@ def await_command(ear):
logging.error('Could not communicate with arthur over socket.')
def new_jobs(now):
for current in repos:
#To prevent repos at the 'bottom' of the dictionary from getting neglected when mirror is under unusual load (and merlin is running at MAX_JOBS)
keys = repos.keys()
random.shuffle(keys)
for current in keys:
if len(jobs) >= MAX_JOBS:
break
if now <= repos[current]['last-attempt'] + mintime: