Debouncer and friends for Python
Project description
Asyncio Debouncer
Description
This Python package provides a debounce decorator using asyncio, ensuring function execution is managed within the asyncio event loop without spawning new threads. It's designed for rate-limiting function calls in asynchronous Python applications.
📦 Installation
Pip
pip install python-debouncer
Poetry
poetry add python-debouncer
🚀 Usage
Import the decorator and apply it to your async functions:
from debouncer import DebounceOptions, debounce
@debounce(wait=.5, options=DebounceOptions(trailing=True, leading=False, time_window=3))
async def your_function():
# Function body
⚠️ Important Note
maxWait
in Lodash implementation is renamed to time_window
here, I think semantically it makes more sense.
🎉 Demo
See demo.py
for a usage example.
Requirements
- Python 3.9+
- asyncio library
Contributing
Contributions are welcome. Please fork the repository and open a pull request.
License
This project is released under the Apache-2.0 License. See the LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python_debouncer-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b80f6ed74131b6f24fe4a08277fb69e51c7d4367fa0bb41bb47f3590439ebdca |
|
MD5 | 720621e9cb4df0affe57cb68ef69c041 |
|
BLAKE2b-256 | f5ac0c8c1f9d125938741c5ea99a25383dfa9c5940e62de844f972073147018b |