async def _handle_client(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
        """Handles connection from a client.

        Validates requests, sends request body to DeepPavlov model, sends responses to client.

        """
        addr = writer.get_extra_info('peername')
        log.info(f'handling connection from {addr}')
        while True:
            header = await reader.read(4)
            if not header:
                log.info(f'closing connection from {addr}')
                writer.close()
                break
            elif len(header) != 4:
                error_msg = f'header "{header}" length less than 4 bytes'
                log.error(error_msg)
                response = self._response(error_msg)
            else:
                data_len = unpack(HEADER_FORMAT, header)[0]
                request_body = await reader.read(data_len)
                try:
                    data = json.loads(request_body)
                    response = await self._interact(data)
                except ValueError:
                    error_msg = f'request "{request_body}" type is not json'
                    log.error(error_msg)
                    response = self._response(error_msg)
            writer.write(response)
            await writer.drain()
Handles connection from a client.

        Validates requests, sends request body to DeepPavlov model, sends responses to client.

        
deeppavlov/utils/socket/socket.py