WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
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: 4 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
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
3 participants
Converted from issue

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