Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the asynchronous requests library like aiohttp to make requests without waiting for them to be completed.

Here's an example:

import aiohttp
import asyncio

async def fetch(session, url):
    async with session.get(url) as response:
        return await response.text()

async def main():
    async with aiohttp.ClientSession() as session:
        # send request without waiting for response
        session.get('http://example.com')

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

In this example, we use aiohttp to create an asynchronous session and then issue a request using the session.get() method without waiting for the response. The event loop will continue to run other tasks while the request is being sent.