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.
Asked: 2023-06-28 14:51:20 +0000
Seen: 8 times
Last updated: Jun 28 '23