bohea / sanic-limiter

Provides rate limiting features for Sanic. Supports in-memory, redis and memcache as storage.
MIT License
85 stars 14 forks source link

Does this use the blocking redis client? #6

Open dmarkey opened 6 years ago

dmarkey commented 6 years ago

It seems that limits is used here, but wouldn't it use the blocking non asyncio redis client and block the asyncio event loop?

bohea commented 6 years ago

yes it would...

在2018年03月16日 19:01,David 写道:

It seems that limits is used here, but wouldn't it use the blocking non asyncio redis client and block the asyncio event loop?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dmarkey commented 6 years ago

:( should probably only support local memory then.

bohea commented 6 years ago

good point,any idea to fix?

how about put limit into a thread and use await to avoiding block 在2018年03月16日 19:07,David 写道:

:( should probably only support local memory then.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dmarkey commented 6 years ago

You may have to abandon limits and create an asyncio compatible version?

hynek commented 4 years ago

You can always run blocking sync code in a thread pool: https://docs.python.org/3.8/library/asyncio-eventloop.html#asyncio.loop.run_in_executor