Esempio n. 1
0
    def test_publish_callback_exc(self, metrics):
        fut = Future()
        fut.set_exception(Exception())
        published_callback("topic", time.time(), fut)

        metrics["PUBLISHED_MESSAGES"].labels.assert_called_with(
            stream_id="topic", partition=-1, error="Exception")
        metrics["PUBLISHED_MESSAGES"].labels().inc()
Esempio n. 2
0
    def _execute_http_client_method(self, host, uri, client_method, waited, callback):
        if waited and (self.is_finished() or self.finish_group.is_finished()):
            handler_logger.info(
                'attempted to make waited http request to %s %s in finished handler, ignoring', host, uri
            )

            future = Future()
            future.set_exception(AbortAsyncGroup())
            return future

        if waited and callable(callback):
            callback = self.check_finished(callback)

        future = client_method(callback)

        if waited:
            self.finish_group.add_future(future)

        return future