Beispiel #1
0
    def test_parse_config(self):

        print('\n\n----------  Config Parser Test Start -------------\n')

        config_file = 'config.yml'
        full_path = os.path.join(os.path.dirname(__file__), config_file)

        config_data = ConfigParser.parse(full_path)

        self.assertIsNotNone(config_data)

        print(repr(config_data))

        self.assertEqual(1, len(config_data))
        hello = config_data['hello']

        self.assertIsNotNone(hello)

        endpoint = hello['endpoint']

        self.assertEqual('hello-python', endpoint)

        print('\n----------  Config Parser Test Finished -------------\n')
    def test_parse_config(self):

        print('\n\n----------  Config Parser Test Start -------------\n')

        config_file = 'config.yml'
        full_path = os.path.join(os.path.dirname(__file__), config_file)

        config_data = ConfigParser.parse(full_path)

        self.assertIsNotNone(config_data)

        print(repr(config_data))

        self.assertEqual(1, len(config_data))
        hello = config_data['hello']

        self.assertIsNotNone(hello)

        endpoint = hello['endpoint']

        self.assertEqual('hello-python', endpoint)


        print('\n----------  Config Parser Test Finished -------------\n')
    logging.info('mod = ' + parts[0])
    logging.info('name = ' + parts[1])

    mod = __import__(parts[0])
    worker_factory = getattr(mod, parts[1])

    return worker_factory


if __name__ == '__main__':
    args = parser.get_args()
    config_file = args.config

    logging.info('Config file = ' + config_file)

    config = ConfigParser.parse(config_file)
    for key in config.keys():
        config_data = config[key]
        logging.info('Config Data = ' + str(config))
        num_workers = config_data['instances']
        worker_name = config_data['worker']
        id_generator = IdGenerator()

        worker_factory = get_factory(worker_name)

        for i in range(int(num_workers)):
            id = id_generator.next_id()
            p = Process(target=start_worker,
                        args=(
                            worker_factory,
                            config_data,
    logging.info('mod = ' + parts[0])
    logging.info('name = ' + parts[1])

    mod = __import__(parts[0])
    worker_factory = getattr(mod, parts[1])

    return worker_factory


if __name__ == '__main__':
    args = parser.get_args()
    config_file = args.config

    logging.info('Config file = ' + config_file)

    config = ConfigParser.parse(config_file)
    for key in config.keys():
        config_data = config[key]
        logging.info('Config Data = ' + str(config))
        num_workers = config_data['instances']
        worker_name = config_data['worker']
        id_generator = IdGenerator()

        worker_factory = get_factory(worker_name)

        for i in range(int(num_workers)):
            id = id_generator.next_id()
            p = Process(target=start_worker,
                        args=(worker_factory, config_data, id,))
            p.start()