Пример #1
0
 def __start_commit_log_consumer(self, timeout=None):
     """
     Starts running the commit log consumer.
     """
     stop_request_event = threading.Event()
     start_event = threading.Event()
     result = execute(
         functools.partial(
             run_commit_log_consumer,
             cluster_name=self.cluster_name,
             consumer_group=f"{self.consumer_group}:sync:{uuid.uuid1().hex}",
             commit_log_topic=self.commit_log_topic,
             synchronize_commit_group=self.synchronize_commit_group,
             partition_state_manager=self.__partition_state_manager,
             start_event=start_event,
             stop_request_event=stop_request_event,
         ))
     start_event.wait(timeout)
     return result, stop_request_event
Пример #2
0
 def __start_commit_log_consumer(self, timeout=None):
     """
     Starts running the commit log consumer.
     """
     stop_request_event = threading.Event()
     start_event = threading.Event()
     result = execute(
         functools.partial(
             run_commit_log_consumer,
             bootstrap_servers=self.bootstrap_servers,
             consumer_group='{}:sync:{}'.format(self.consumer_group, uuid.uuid1().hex),
             commit_log_topic=self.commit_log_topic,
             synchronize_commit_group=self.synchronize_commit_group,
             partition_state_manager=self.__partition_state_manager,
             start_event=start_event,
             stop_request_event=stop_request_event,
         ),
     )
     start_event.wait(timeout)
     return result, stop_request_event
Пример #3
0
 def __start_commit_log_consumer(self, timeout=None):
     """
     Starts running the commit log consumer.
     """
     stop_request_event = threading.Event()
     start_event = threading.Event()
     result = execute(
         functools.partial(
             run_commit_log_consumer,
             bootstrap_servers=self.bootstrap_servers,
             consumer_group='{}:sync:{}'.format(self.consumer_group,
                                                uuid.uuid1().hex),
             commit_log_topic=self.commit_log_topic,
             synchronize_commit_group=self.synchronize_commit_group,
             partition_state_manager=self.__partition_state_manager,
             start_event=start_event,
             stop_request_event=stop_request_event,
         ), )
     start_event.wait(timeout)
     return result, stop_request_event
Пример #4
0
def test_execute():
    assert execute(thread.get_ident).result() != thread.get_ident()

    with pytest.raises(Exception):
        assert execute(mock.Mock(side_effect=Exception("Boom!"))).result()