ClientResponse object has no attribute 'status_code'

3.1k Views Asked by At

I am trying to push data to OpenTSDB using asyncio and aiohttp. I am getting the error AttributeError: 'ClientResponse' object has no attribute 'status_code'

My environment details:

  • Python: 3.8
  • aiohttp: 3.8.1

My Code:

    async def get_session(self):
        if not self.session:
            self.session = aiohttp.ClientSession()
        return self.session

    async def push(self, metrics):
        json_data = self.build_json_data(metrics)
        if not json_data:
            return

        sess = await self.get_session()
        r = await sess.post(self.url, data=json_data)
        LOGGER.debug("result code: %s", r.status_code)

What i am doing wrong? Any pointers to resolve this issue.

0

There are 0 best solutions below