⏱️ WaitManager-Web
Intelligent rate limiting for Flask, FastAPI, and Django — inspired by Fast Rub's WaitManager.
✨ Features
- 🔌 Plug & Play — Works with Flask, FastAPI, and Django
- 🧠 Smart Rate Limiting — Low/Medium/High traffic tiers with automatic wait calculation
- 📊 Per-Channel Tracking — Separate limits for API, login, upload, download, search, signup
- 🎯 Per-IP Tracking — Track each client separately
- 🔧 Fully Customizable — Custom channels, custom sleep callback, auto-tracking
- 🪶 Zero Dependencies — Core module uses only Python stdlib
- 📦 Optional Dependencies — Install only what you need
📦 Installation
pip install waitmanager-web # Core only
pip install waitmanager-web[flask] # + Flask
pip install waitmanager-web[fastapi] # + FastAPI
pip install waitmanager-web[django] # + Django
pip install waitmanager-web[all] # Everything
🚀 Quick Start
Flask
from flask import Flask
from waitmanager.flask import FlaskWaitManager
app = Flask(__name__)
wm = FlaskWaitManager(low_traffic=100, high_wait=2.0, auto_track=True)
wm.init_app(app)
@app.route("/api/data")
@wm.limit(channel="api")
def get_data():
return {"status": "ok"}
@app.route("/login", methods=["POST"])
@wm.limit(channel="login", max_requests=5, window=300)
def login():
return {"status": "ok"}
FastAPI
from fastapi import FastAPI, Depends
from waitmanager import WaitManager
from waitmanager.fastapi import RateLimiter
app = FastAPI()
wm = WaitManager(low_traffic=100, high_wait=2.0)
limiter = RateLimiter(wm)
@app.get("/api/data")
async def get_data(_=Depends(limiter.limit("api"))):
return {"status": "ok"}
@app.post("/login")
async def login(_=Depends(limiter.limit("login", max_requests=5, window=300))):
return {"status": "ok"}
Django
# settings.py
MIDDLEWARE = [
"waitmanager.django.WaitManagerMiddleware",
...
]
WAITMANAGER_CONFIG = {
"low_traffic": 100,
"high_wait": 2.0,
"auto_track": True,
}
# views.py
from waitmanager.django import limit
@limit(channel="api")
def api_view(request):
return JsonResponse({"status": "ok"})
@limit(channel="login", max_requests=5, window=300, block=True)
def login_view(request):
return JsonResponse({"status": "ok"})
⚙️ Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
low_traffic |
int | 100 | Max requests for "low traffic" |
medium_traffic |
int | 200 | Max requests for "medium traffic" |
low_wait |
float | 0.0 | Delay for low traffic (seconds) |
medium_wait |
float | 0.5 | Delay for medium traffic |
high_wait |
float | 2.0 | Delay for high traffic |
time_window |
float | 60.0 | Time window (seconds) |
auto_track |
bool | False | Auto-track every request |
per_ip |
bool | True | Track per IP address |
sleep_callback |
callable | None | Custom wait time function |
channels |
list | None | Custom channel names |
🎯 Custom Sleep Callback
def my_logic(channel, messages_count, last_time, **kwargs):
if channel == "login" and messages_count > 3:
return 30.0 # 30 second penalty
return None # Use default logic
wm = WaitManager(sleep_callback=my_logic)
🧪 Custom Channels
wm = WaitManager(channels=["api", "login", "payment", "export"])
📄 License
MIT © OandONE
🙏 Acknowledgments
Inspired by Fast Rub's WaitManager — the smartest rate limiter for Rubika bots.
"Good software is built on pain. WaitManager was built on Rubika's API." — OandONE
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
waitmanager_web-0.1.2.tar.gz
(8.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file waitmanager_web-0.1.2.tar.gz.
File metadata
- Download URL: waitmanager_web-0.1.2.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5df94bd274281935f0b92557b3d1220b061d2bc1afeeb75ebf3cb2ac1db86a06
|
|
| MD5 |
b2f0fd526cb10533c5ae7d60aaa0808f
|
|
| BLAKE2b-256 |
c91909654f28a09db31ce886d08bf407aff8a3fb974d91b795960396e77458c4
|
File details
Details for the file waitmanager_web-0.1.2-py3-none-any.whl.
File metadata
- Download URL: waitmanager_web-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40fdff4e2d01f722be602497bb4ace1751df6a28a17bb51c6343aa16f7a1450c
|
|
| MD5 |
18dd3c80e883cb0bdd25a99f1d98d27b
|
|
| BLAKE2b-256 |
8d244185d2374c5bd0e49a8463d19c4cf0e82ddd326103a3cc446fab04b0e5d4
|