Skip to content

I don't understand how I am supposed to use it #63

@ev-agelos

Description

@ev-agelos

The API I am trying against has a limit of 250 requests per minute. Whatever I try I get 429 responses, it doesnt seep to "sleep" or "slow down" after 250 requests

async def main():
    limiter = AsyncLimiter(250, 60)
    async with client as cl:  # httpx async client
        # for i in range(400):
        #     async with limiter:
        async with limiter:
            for i in range(400):
                await cl.get(url)

asyncio.run(main())

Furthermore, the code I am trying to make use of your library has this form:

async def get_name():
    # api request
    ...

async def get_last_name():
    # another api request
    ...

async def get_user_data():
    name = await get_name()
    last_name = await get_last_name()
    return name, last_name

async def main():
    coros = [get_user_data() for user in many_users()]
    for result in asyncio.gather(*coros):
        # handle result

Is it possible somehow to apply the limiter in such structure?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions