Exemplo n.º 1
0
  def test_stop_no_scheduler(self):
    """ Test AgentRunner with parameters """
    sched = {"scheduling":{"name": "A SCHEDULER"}}
    instance = Mock()
    mock = Mock()

    co = AgentRunner(instance)
    co._init_scheduler = mock

    with self.assertRaisesRegexp(AgentRunnerException, "No scheduler found"):
      co.stop()
Exemplo n.º 2
0
  def test_stop_a_scheduler(self):
    """ Test AgentRunner with parameters """
    sched = {"scheduling":{"name": "A SCHEDULER"}}
    mock = Mock()
    mocked_sched = Mock()
    instance = Mock()

    co = AgentRunner(instance)
    co.scheduler = mocked_sched

    co.stop()
    mocked_sched.stop.assert_called_with()
Exemplo n.º 3
0
def main():
  configurator= AgentConfigurator({"folder":"/home/jc", "filename":"clu.conf"})

  configurator.loadfile()
  configurator.loadclasses()
  configurator.initalize_all()

  runners = []
  try:
    for agent in configurator.agents:
      runner = AgentRunner(agent)
      runners.append(runner.start())
    # keep the main thread alive
    while True:
      time.sleep(0.1)
  except KeyboardInterrupt, ex:
    LOGGER.warning("ctrl-C catched, shuting down all threads")
    for runner in runners:
      runner.stop()
      runner.join()