How do I use asyncio.Lock to stop a function from running more than once concurrently?
Looking into asyncio.Lock to stop a function from running at the same time as another. But am a little confused. Essentially what I need is for a cache update function to be locked if multiple requests are made to it at the same time (By the same user), or within close proximity of each other. This will prevent the external api from rate limiting this users token. app.ctx.cache = {} # {userToken: {user_information...} app.route(user_information, "/api/user_information") async def user_information(request): token = request.get("user_token") cooldown = 5 last_update = datetime.utcnow() - timedel
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.