import json


async def _sendLambdaRequest(session, lambdaUrl, anomalyServiceObj):
    """
    Async method to send anomaly detection request to lambda
    :param session: ClientSession instance for aiohttp
    :param lambdaUrl: AWS Lambda invocation endpoint
    :param anomalyServiceObject: Dict containing parameter data for anomaly service
    """
    resp = await session.post(lambdaUrl, data=json.dumps(anomalyServiceObj))
    print(f"Request sent for {anomalyServiceObj['dimValObj']['dimVal']}")
    responseData = await resp.json()
    if(responseData.get("message") == "Endpoint request timed out"):
        resp = await session.post(lambdaUrl, data=json.dumps(anomalyServiceObj))
        print(f"Retrying request for {anomalyServiceObj['dimValObj']['dimVal']}")
        responseData = await resp.json()
    return responseData