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

Why using synchronous get in flags_asyncio.py #40

Open
ngokchaoho opened this issue Dec 13, 2023 · 0 comments
Open

Why using synchronous get in flags_asyncio.py #40

ngokchaoho opened this issue Dec 13, 2023 · 0 comments

Comments

@ngokchaoho
Copy link

When downloading the flags in

async def get_flag(client: AsyncClient, cc: str) -> bytes:  4
    url = f'{BASE_URL}/{cc}/{cc}.gif'.lower()
    resp = await client.get(url, timeout=6.1,
                                  follow_redirects=True)  5
    return resp.read()  6

it seems that we read the response using .read() which is synchronous, why don't we

return await resp.aread()

instead?

The explanation seems to be for client.get() where it is doing network IO asynchrnously provided by httpx. But not for read()

6

    Network I/O operations are implemented as coroutine methods, so they are driven asynchronously by the asyncio event loop.
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

No branches or pull requests

1 participant