def do_push(push_url, body, address, signing_key, reviewee_id):
path = '/' + push_url.split('/', 3)[-1]
method = 'POST'
backoff = 5
retries = 10
terminate = False
async with aiohttp.ClientSession() as session:
while not terminate:
timestamp = int(time.time())
signature = sign_request(signing_key, method, path, timestamp, body)
with aiohttp.Timeout(10):
async with session.post(push_url,
headers={
'content-type': 'application/json',
TOSHI_SIGNATURE_HEADER: signature,
TOSHI_ID_ADDRESS_HEADER: address,
TOSHI_TIMESTAMP_HEADER: str(timestamp)},
data=body) as response:
if response.status == 204 or response.status == 200:
terminate = True
else:
log.error("Error updating user details")
log.error("URL: {}".format(push_url))
log.error("User Address: {}".format(reviewee_id))
retries -= 1
if retries <= 0:
terminate = True
await asyncio.sleep(backoff)
backoff = min(backoff + 5, 30)
评论列表
文章目录