ages.append(age)
return ages
- def need_wait(self, now):
+ def need_wait(self, now, imaginary=[]):
ages = self._cache_scan(now)
+ ages += imaginary
ages.sort()
debug('Fetcher ages ' + `ages`)
min_age = 1
pa.pi = None
def pirate_info(pa):
- if not pa.pi and not fetcher.need_wait(time.time()):
- pa.pi = PirateInfo(pa.name, 3600)
+ now = time.time()
+ if pa.pi:
+ age = now - pa.pi_fetched
+ guide = random.randint(120,240)
+ if age <= guide:
+ return pa.pi
+ debug('PirateAboard refresh %d > %d %s' % (
+ age, guide, pa.name))
+ imaginary = [2,6]
+ else:
+ imaginary = [1]
+ wait = fetcher.need_wait(now, imaginary)
+ if wait:
+ debug('PirateAboard fetcher not ready %d' % wait)
+ return pa.pi
+ pa.pi = PirateInfo(pa.name, 600)
+ pa.pi_fetched = now
return pa.pi
class ChatLogTracker: