def test_runforever_select_dispatcher_exitnow(self): options = DummyOptions() supervisord = self._makeOne(options) pconfig = DummyPConfig( options, 'foo', '/bin/foo', ) gconfig = DummyPGroupConfig(options, pconfigs=[pconfig]) pgroup = DummyProcessGroup(gconfig) from docker_supervisor.medusa import asyncore_25 as asyncore exitnow = DummyDispatcher(readable=True, error=asyncore.ExitNow) pgroup.dispatchers = {6: exitnow} supervisord.process_groups = {'foo': pgroup} options.select_result = [6], [], [] options.test = True self.assertRaises(asyncore.ExitNow, supervisord.runforever)
def test_runforever_select_dispatchers(self): options = DummyOptions() supervisord = self._makeOne(options) pconfig = DummyPConfig( options, 'foo', '/bin/foo', ) gconfig = DummyPGroupConfig(options, pconfigs=[pconfig]) pgroup = DummyProcessGroup(gconfig) readable = DummyDispatcher(readable=True) writable = DummyDispatcher(writable=True) error = DummyDispatcher(writable=True, error=OSError) pgroup.dispatchers = {6: readable, 7: writable, 8: error} supervisord.process_groups = {'foo': pgroup} options.select_result = [6], [7, 8], [] options.test = True supervisord.runforever() self.assertEqual(pgroup.transitioned, True) self.assertEqual(readable.read_event_handled, True) self.assertEqual(writable.write_event_handled, True) self.assertEqual(error.error_handled, True)