I have a Django app and in one of its views I use asyncio in order to make some concurent requests to an external component.
Here is the idea:
import asyncio
async def do_request(project):
result = ...
return result
def aggregate_results(projects: list):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
results = loop.run_until_complete(
asyncio.gather(*(do_request(project) for project in projects))
)
loop.close()
return zip(projects, results)
Well, when I run the tests I get DeprecationWarning: There is no current event loop at this line:
asyncio.gather(*(do_request(project) for project in projects))
How should I interpret this warning and what do I need to change to get rid of it? Thanks!