Comment 1 for bug 1223259

Revision history for this message
Che-Wei Hu (tethu0822) wrote :

Hi, all:

I found that I can get correct response from swift proxy if I do the following modification for ceilometer/objectstore/swift_middleware.py:

class CeilometerMiddleware(object):
    ...
    def __call__(self, env, start_response):
        ...

        def iter_response(iterable):
            if start_response_args[0]:
                start_response(*start_response_args[0])
            """
            bytes_sent = 0
            try:
                for chunk in iterable:
                    if chunk:
                        bytes_sent += len(chunk)
                    yield chunk
            finally:
                self.publish_sample(env,
                                    input_proxy.bytes_received,
                                    bytes_sent)
            """
            return iterable

        try:
            iterable = self.app(env, my_start_response)
        except Exception:
            self.publish_sample(env, input_proxy.bytes_received, 0)
            raise
        else:
            return iter_response(iterable)

I have no idea why the python for loop makes the response become empty.
Could any one else help to check this issue?

Thanks a lot!