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

update readme to real async get #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

acrogenesis
Copy link

Fix #8

@juliusbierk
Copy link

Probably even more correct to do

from requests_threads import AsyncSession

session = AsyncSession(n=100)

async def _main():
    rs = []
    for _ in range(100):
        rs.append(asyncio.ensure_future(session.get('http://httpbin.org/get')))
    for i in range(100):
        rs[i] = await rs[i]
    print(rs)

if __name__ == '__main__':
    session.run(_main)

See https://docs.python.org/3/library/asyncio-future.html#asyncio.ensure_future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

readme example not async?
2 participants