-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Example code from client quickstart not working #3376
Comments
GitMate.io thinks the contributor most likely able to help you is @asvetlov. Possibly related issues are #3175 (aiohttp client timeout does not work), #1309 (Client Tracing), #556 (Example in readme doesn't work as is), #1640 ( Readme client example throws an AssertionError), and #3234 (NameError during WebSockets example in Web Server quickstart docs). |
@caliph007 You can't use async code without loop. Full example of code in Python 3.5-3.6: import asyncio
import aiohttp
async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://httpbin.org/get') as resp:
print(resp.status)
print(await resp.text())
loop = asyncio.get_event_loop()
loop.run_until_complete(main()) Full example of code in Python 3.7 import asyncio
import aiohttp
async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://httpbin.org/get') as resp:
print(resp.status)
print(await resp.text())
asyncio.run(main()) |
|
I think this issue should be reopened. The client quickstart https://docs.aiohttp.org/en/stable/client_quickstart.html has examples that don't work, as @caliph007 noted above |
Please feel free to open a Pull Request with docs update |
I hope I am not fully making a fool of myself.
I am not able to get to work the few lines of the client quickstart code:
in Python 3.6. I get:
That I understand, because
async
became a reserved work in 3.7.But the doc states as dependency
Python 3.5.3+
in Python 3.7 I get:
What am I doing wrong?
Thank you in advance.
The text was updated successfully, but these errors were encountered: