

def _send_event(self, atom):
    headers = {
        'Content-Type': 'application/atom+xml',
    }
    headers = self._get_auth(headers=headers)
    attempts = 0
    status = 0
    while True:
        try:
            res = requests.post(self.url, data=atom, headers=headers, timeout=self.http_timeout)
            status = res.status_code
            if ((status >= 200) and (status < 300)):
                break
            if (status == 401):
                logger.info('Auth expired, reauthorizing...')
                headers = self._get_auth(headers=headers, force=True)
                continue
            if (status == 409):
                logger.debug(('Duplicate message: \n%s' % atom))
                break
            if (status == 400):
                logger.error(('Invalid Content: Server rejected content: \n%s' % atom))
                break
        except requests.exceptions.ConnectionError:
            logger.exception(('Connection error talking to %s' % self.url))
        except requests.exceptions.Timeout:
            logger.exception(('HTTP timeout talking to %s' % self.url))
        except requests.exceptions.HTTPError:
            logger.exception(('HTTP protocol error talking to %s' % self.url))
        except requests.exceptions.RequestException:
            logger.exception(('Unknown exeption talking to %s' % self.url))
        attempts += 1
        wait = min((attempts * self.wait_interval), self.max_wait)
        logger.error(('Message delivery failed, going to sleep, will try again in %s seconds' % str(wait)))
        time.sleep(wait)
    return status

dataset/ETHPy150Open openstack/stacktach-winchester/winchester/pipeline_handler.py AtomPubHandler._send_event/original