I have checked this post (but I cannot reply): aiohttp: rate limiting parallel requests
First of all, I would like to say thanks @Sraw for his comments in the aforementioned post!
However, I have doubts if I am doing well with my current solution:
for convertedJson in allJsons:
.....
.....
tasks.append(asyncio.ensure_future(fetch(env,typeRequest,convertedJson,headers,retries,execution,session)))
await asyncio.sleep(1/800)
results = await asyncio.gather(*tasks,return_exceptions=True)
await session.close()
In my fetch function I am basically doing this:
async def fetch(env,typeRequest,request,headers,retries,execution,session):
.....
.....
async with session.post(url=VALIDATION_API_ENDPOINT,json=request["body_request"],headers=headers,timeout=None,allow_redirects=False) as response:
......
......
jsonF=await response.json()
return jsonF
The thing is that I want to make 800 requests per second. Am I doing it correctly?. I suppose that it is obvious that I am not able to know how long it is going to take to receive the responses. I'd like to know if I am already doing these 800 reqs/sec with this logic, because the server guys told me that I was actually doing around 400 reqs/sec (for me doesn't make sense).
Thanks you all! BR,