Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Why using synchronous get in flags_asyncio.py #40

Copy link
Copy link
Open
@ngokchaoho

Description

@ngokchaoho
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.