-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RedisBucket raising SynchronousOnlyOperation in Django #186
Comments
Probably, its been a long time since I last work with django so things might need some adjustment. |
Thanks for the quick reply. Using release |
I had in mind this test: from asyncio import get_running_loop
from pyrate_limiter import Duration, Rate, InMemoryBucket, Limiter
rates = [Rate(2, Duration.SECOND)]
bucket = InMemoryBucket(rates)
limiter = Limiter(bucket, max_delay=Duration.SECOND)
limiter.try_acquire("some item")
try:
get_running_loop()
except RuntimeError:
pass
else:
raise RuntimeError("an event loop was created") As this is what Django does in the end. But this isn't failing for reasons unknown to me. Same behavior with a Redis bucket. |
Hello, I am having trouble using this library with Django.
Indeed using in a Django view a snippet like:
and then doing an ORM request raise an SynchronousOnlyOperation error. It seems to be raised because an event loop was created.
To me the problem is with pyrate_limiter.abstracts.bucket.Leaker.run that create the problematic event loop. I appreciate calling an async code under the hood allows to regroup code with async context, but it seems to also break the compatibility with Django, isn't it ?
The text was updated successfully, but these errors were encountered: