Skip to content

Custom made async event loop where you can send multiple http requests concurrently with the help of the selectors module.

Notifications You must be signed in to change notification settings

iranzithierry/async-loop

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A custom made event loop with async and await syntax, background tasks, and helper functions, along with concurrent synchronization.

The selectors module makes this all possible.

https://docs.python.org/3/library/selectors.html

Screenshot 2024-06-21 125920

from AsyncLoop import EventLoop, AsyncClient


async def scrape_other_website():
    results = await EventLoop.gather(*[AsyncClient.request("https://www.google.com/") for _ in range(100)])
    return results

async def scrape_website(url):
    first_result = await scrape_other_website()
    print(first_result)
    second_result = await EventLoop.gather(*[AsyncClient.request(url) for _ in range(20)])
    return second_result

async def main():
    url = "https://github.com/"
    task_1 = EventLoop.create_task(scrape_website(url))
    task_2 = EventLoop.create_task(scrape_other_website())
    result = await EventLoop.gather(task_1,task_2)
    print(result)

EventLoop.run(main())

About

Custom made async event loop where you can send multiple http requests concurrently with the help of the selectors module.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%