Exemplo n.º 1
0
    def _test_start_watchers_warmup_delay(self):
        yield self.start_arbiter()
        called = []

        @tornado.gen.coroutine
        def _sleep(duration):
            called.append(duration)
            loop = get_ioloop()
            yield tornado.gen.Task(loop.add_timeout, time() + duration)

        watcher_mod.tornado_sleep = _sleep

        watcher = MockWatcher(name='foo', cmd=SLEEP % 1, priority=1)
        yield self.arbiter.start_watcher(watcher)

        self.assertTrue(called, [self.arbiter.warmup_delay])

        # now make sure we don't sleep when there is a autostart
        watcher = MockWatcher(name='foo',
                              cmd='serve',
                              priority=1,
                              autostart=False)
        yield self.arbiter.start_watcher(watcher)
        self.assertTrue(called, [self.arbiter.warmup_delay])
        yield self.stop_arbiter()
Exemplo n.º 2
0
 def test_start_watchers_with_autostart(self):
     watcher = MockWatcher(name='foo',
                           cmd='serve',
                           priority=1,
                           autostart=False)
     arbiter = Arbiter([], None, None, check_delay=-1)
     arbiter.start_watcher(watcher)
     self.assertFalse(getattr(watcher, 'started', False))
Exemplo n.º 3
0
 def test_start_watcher(self):
     watcher = MockWatcher(name='foo', cmd='serve', priority=1)
     arbiter = Arbiter([], None, None, check_delay=-1)
     yield arbiter.start_watcher(watcher)
     self.assertTrue(watcher.is_active())
Exemplo n.º 4
0
 def test_start_watcher(self):
     watcher = MockWatcher(name='foo', cmd='serve', priority=1)
     arbiter = Arbiter([], None, None, check_delay=-1)
     yield arbiter.start_watcher(watcher)
     self.assertTrue(watcher.is_active())