コード例 #1
0
ファイル: handlers_bot.py プロジェクト: rmistry/luci-py
 def _cmd_sleep(self, sleep_streak, quarantined):
   out = {
     'cmd': 'sleep',
     'duration': task_scheduler.exponential_backoff(sleep_streak),
     'quarantined': quarantined,
   }
   self.send_response(out)
コード例 #2
0
 def _cmd_sleep(self, sleep_streak, quarantined):
     out = {
         'cmd': 'sleep',
         'duration': task_scheduler.exponential_backoff(sleep_streak),
         'quarantined': quarantined,
     }
     self.send_response(out)
コード例 #3
0
ファイル: handlers_bot.py プロジェクト: rmoorman/luci-py
 def _cmd_sleep(self, sleep_streak, quarantined):
     duration = task_scheduler.exponential_backoff(sleep_streak)
     logging.debug('Sleep: streak: %d; duration: %ds; quarantined: %s',
                   sleep_streak, duration, quarantined)
     out = {
         'cmd': 'sleep',
         'duration': duration,
         'quarantined': quarantined,
     }
     self.send_response(out)
コード例 #4
0
 def test_exponential_backoff(self):
     self.mock(task_scheduler.random, 'random',
               lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK)
     self.mock(utils, 'is_canary', lambda: False)
     data = [
         (0, 2),
         (1, 2),
         (2, 3),
         (3, 5),
         (4, 8),
         (5, 11),
         (6, 17),
         (7, 26),
         (8, 38),
         (9, 58),
         (10, 60),
         (11, 60),
     ]
     for value, expected in data:
         actual = int(round(task_scheduler.exponential_backoff(value)))
         self.assertEqual(expected, actual, (value, expected, actual))
コード例 #5
0
 def test_exponential_backoff(self):
   self.mock(
       task_scheduler.random, 'random',
       lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK)
   self.mock(utils, 'is_canary', lambda: False)
   data = [
     (0, 2),
     (1, 2),
     (2, 3),
     (3, 5),
     (4, 8),
     (5, 11),
     (6, 17),
     (7, 26),
     (8, 38),
     (9, 58),
     (10, 60),
     (11, 60),
   ]
   for value, expected in data:
     actual = int(round(task_scheduler.exponential_backoff(value)))
     self.assertEqual(expected, actual, (value, expected, actual))
コード例 #6
0
 def test_exponential_backoff_quick(self):
   self.mock(
       task_scheduler.random, 'random',
       lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK - 0.01)
   self.assertEqual(1.0, task_scheduler.exponential_backoff(235))
コード例 #7
0
ファイル: handlers_bot.py プロジェクト: eakuefner/luci-py
 def _cmd_sleep(self, sleep_streak, quarantined):
     out = {"cmd": "sleep", "duration": task_scheduler.exponential_backoff(sleep_streak), "quarantined": quarantined}
     self.send_response(out)
コード例 #8
0
 def test_exponential_backoff_quick(self):
     self.mock(task_scheduler.random, 'random',
               lambda: task_scheduler._PROBABILITY_OF_QUICK_COMEBACK - 0.01)
     self.assertEqual(1.0, task_scheduler.exponential_backoff(235))