chiark / gitweb /
Add +/-0.5s to chat log poll times to make behaviour less clumpy
[ypp-sc-tools.db-live.git] / yoweb-scrape
index 31c75ae9f0a3ad774b1e2d3b5475f159933da6f8..e3a7c8c19c7b97f5e7c1e7dbb30f3418b101859a 100755 (executable)
@@ -43,6 +43,7 @@ import re as regexp
 import random
 import curses
 import termios
+import random
 from optparse import OptionParser
 from StringIO import StringIO
 
@@ -142,12 +143,14 @@ class Fetcher:
                min_age = 1
                need_wait = 0
                for age in ages:
-                       if age < min_age and age < 300:
+                       if age < min_age and age <= 5:
                                debug('Fetcher   morewait min=%d age=%d' %
                                        (min_age, age))
                                need_wait = max(need_wait, min_age - age)
                        min_age += 3
                        min_age *= 1.25
+               if need_wait > 0:
+                       need_wait += random.random() - 0.5
                return need_wait
 
        def _rate_limit_cache_clean(self, now):
@@ -476,7 +479,7 @@ class PirateAboard:
                                return pa.pi
                        debug('PirateAboard refresh %d > %d  %s' % (
                                age, guide, pa.name))
-                       imaginary = [2,6]
+                       imaginary = [2,4]
                else:
                        imaginary = [1]
                wait = fetcher.need_wait(now, imaginary)
@@ -971,7 +974,7 @@ def do_track_chat_log(args, bu):
                track.catchup()
                if track.changed():
                        print track
-               sleep(1)
+               sleep(0.5 + 0.5 * random.random())
 
 #----- ship management aid -----