Example #1
0
 def _fetch_executor(self):
     executor = worker_executor.WorkerTaskExecutor(
         uuidutils.generate_uuid(),
         TEST_EXCHANGE, [TEST_TOPIC],
         transport='memory',
         transport_options={
             'polling_interval': POLLING_INTERVAL,
         })
     return executor
 def executor(self, reset_main_mock=True, **kwargs):
     executor_kwargs = dict(uuid=self.executor_uuid,
                            exchange=self.executor_exchange,
                            topics=[self.executor_topic],
                            url=self.broker_url)
     executor_kwargs.update(kwargs)
     ex = executor.WorkerTaskExecutor(**executor_kwargs)
     if reset_main_mock:
         self.resetMainMock()
     return ex
Example #3
0
 def executor(self, reset_master_mock=True, **kwargs):
     executor_kwargs = dict(uuid=self.executor_uuid,
                            exchange=self.executor_exchange,
                            workers_info=self.executor_workers_info,
                            url=self.broker_url)
     executor_kwargs.update(kwargs)
     ex = executor.WorkerTaskExecutor(**executor_kwargs)
     if reset_master_mock:
         self._reset_master_mock()
     return ex
Example #4
0
 def _task_executor_factory(self):
     try:
         return self._options['executor']
     except KeyError:
         return executor.WorkerTaskExecutor(
             uuid=self._flow_detail.uuid,
             url=self._options.get('url'),
             exchange=self._options.get('exchange', 'default'),
             topics=self._options.get('topics', []),
             transport=self._options.get('transport'),
             transport_options=self._options.get('transport_options'),
             transition_timeout=self._options.get('transition_timeout',
                                                  pr.REQUEST_TIMEOUT))
Example #5
0
 def _fetch_task_executor(cls, options, flow_detail):
     try:
         e = options['executor']
         if not isinstance(e, executor.WorkerTaskExecutor):
             raise TypeError("Expected an instance of type '%s' instead of"
                             " type '%s' for 'executor' option" %
                             (executor.WorkerTaskExecutor, type(e)))
         return e
     except KeyError:
         return executor.WorkerTaskExecutor(
             uuid=flow_detail.uuid,
             url=options.get('url'),
             exchange=options.get('exchange', 'default'),
             retry_options=options.get('retry_options'),
             topics=options.get('topics', []),
             transport=options.get('transport'),
             transport_options=options.get('transport_options'),
             transition_timeout=options.get('transition_timeout',
                                            pr.REQUEST_TIMEOUT))
Example #6
0
 def test_creation_custom_executor(self):
     ex = executor.WorkerTaskExecutor('a', 'test-exchange', ['test-topic'])
     eng = self._create_engine(executor=ex)
     self.assertIs(eng._task_executor, ex)
     self.assertIsInstance(eng._task_executor, executor.WorkerTaskExecutor)
Example #7
0
 def _task_executor_cls(self):
     return executor.WorkerTaskExecutor(**self._executor_config)