0

All the requests are working normally but after 90% of the tasks the responds get hung and timeout.

In the following code, if you change n_requests to 1000 or 10 the problem is still there and it seems always to be 10% which wont get a response.

It only seems to work with 2 requests (n_requests = 2):

import asyncio
import aiohttp

n_requests = 100

async def make_request(session, req_n):
    url = f"https://tbit-web.de/exec/ximg.php?fid={req_n}"
    print(req_n)
    async with session.get(url) as resp:
        print(req_n, "finish")

async def main():
    async with aiohttp.ClientSession() as session:
        counternr = 0
        while counternr < 9999:
            await asyncio.gather(
                *[make_request(session, i) for i in range(counternr, counternr + n_requests)]
        )
            counternr= n_requests + counternr

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
  • Code seems to work fine on Windows but not on Ubuntu I even use the same Python version & IDE (Python 3.6 & PyCharm) –  Nov 06 '19 at 23:24
  • Most likely running out of space in the thread in the Ubuntu box, and waiting for subsequent calls to clear up. Why do you have the `while counternr` line? – felipe Nov 19 '19 at 15:10

0 Answers0