def _send_simple_push(endpoint, version, max_retries=3, _retry_count=0):

    try:
        r = requests.put(endpoint, 'version={}'.format(version))
    except RequestException as e:
        # This is something like connection error, not a server error.
        if _retry_count < max_retries:
            return _send_simple_push(endpoint, version, max_retries, _retry_count + 1)
        else:
            logger.error('SimplePush PUT failed: %s', e)
            return

    # If something does wrong, the SimplePush server should give back json encoded error messages.
    if r.status_code >= 400:
        try:
            data = r.json()
        except simplejson.scanner.JSONDecodeError:
            logger.error('SimplePush error (also not JSON?!): %s %s', r.status_code, r.text)
            return

        if r.status_code == 503 and data['errno'] == 202 and _retry_count < max_retries:
            return _send_simple_push(endpoint, version, max_retries, _retry_count + 1)
        else:
            logger.error('SimplePush error: %s %s', r.status_code, r.json())
Hit a simple push endpoint to send a notification to a user.
dataset/ETHPy150Open mozilla/kitsune/kitsune/notifications/tasks.py/_send_simple_push