Skip to content

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

Answered by mjpieters
ev-agelos asked this question in Q&A
Discussion options

You must be logged in to vote

Your error lies here:

        async with limiter:
            for i in range(400):
                await cl.get(url)

The whole block under async with limiter: is limited to 256 executions per 60 seconds, but you loop inside that block. Put the loop outside of the limiter:

        for i in range(400):
            async with limiter:
                await cl.get(url)

Now execution passes from for to the async with limiter: block, which can then control how fast await cl.get(url) is called.

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

Create a limiter in main() and pass it into get_user_data() so it is shared between coroutines:

async def get_user_data(limiter):
    with 

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mjpieters
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #63 on March 04, 2022 17:59.