Hacer 1 millón de solicitudes con aiohttp / asyncio, literalmente
Seguí este tutorial:https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html y todo funciona bien cuando estoy haciendo unas 50 000 solicitudes. Pero necesito hacer 1 millón de llamadas a la API y luego tengo un problema con este código:
url = "http://some_url.com/?id={}"
tasks = set()
sem = asyncio.Semaphore(MAX_SIM_CONNS)
for i in range(1, LAST_ID + 1):
task = asyncio.ensure_future(bound_fetch(sem, url.format(i)))
tasks.add(task)
responses = asyncio.gather(*tasks)
return await responses
Debido a que Python necesita crear 1 millón de tareas, básicamente solo se retrasa y luego imprimeKilled
mensaje en terminal. ¿Hay alguna forma de usar un generador en lugar de un conjunto preestablecido (o lista) de URL? Gracias.