Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve four things from the web with concurrency #938

Closed
wants to merge 3 commits into from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jun 19, 2016

What do these changes do?

Add a simple example to show how to create a client that gathers multiple web resources concurrently .

Are there changes in behavior for the user?

Accelerate the learning curve for real world use of aiohttp for clients such as web crawlers, etc.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

Add a simple example to show how to create a client that gathers multiple web resources concurrently . It should be quite helpful for readers to understand how to use aiohttp to gather several remote resources concurrently.

Add a simple example to show how to create a client that gathers multiple web resources _concurrently_ .

I am not sure if this example is serial or concurrent.  :-(  If it is serial then it would be quite helpful for readers to understand how to make it concurrent.
@coveralls
Copy link

coveralls commented Jun 19, 2016

Coverage Status

Coverage remained the same at 98.486% when pulling 358269c on cclauss:patch-3 into 65d385e on KeepSafe:0.21.

@coveralls
Copy link

coveralls commented Jun 19, 2016

Coverage Status

Coverage remained the same at 98.486% when pulling 6ed388c on cclauss:patch-3 into 65d385e on KeepSafe:0.21.

loop = asyncio.get_event_loop()
with aiohttp.ClientSession(loop=loop) as session:
coroutines = [fetch(session, url) for url in URLS]
pages = [loop.run_until_complete(coroutine) for coroutine in coroutines]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be aggregated with asyncio.gather instead?

Thanks @bhuman, asyncio.gather() was the correct way to go...

I had been doing [other experiments](https://github.com/cclauss/asyncio_hacks/blob/master/factorial_futures.py) to get these asynchronous execution ideas clear in my head.
@cclauss
Copy link
Contributor Author

cclauss commented Jun 21, 2016

Thanks @buhman Fixed above.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
@cclauss cclauss deleted the patch-3 branch October 29, 2019 17:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants