⏱️ 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
Metadata
Release files for waitmanager-web 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| waitmanager_web-0.1.2.tar.gz | 8.2 kB | Without provenance | Details for waitmanager_web-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| waitmanager_web-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for waitmanager_web-0.1.2-py3-none-any.whl |
Total release size: 16.2 kB
Release files / waitmanager_web-0.1.2.tar.gz
| Download URL | waitmanager_web-0.1.2.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5df94bd274281935f0b92557b3d1220b061d2bc1afeeb75ebf3cb2ac1db86a06
|
|
BLAKE2b-256 checksum How to use checksums |
c91909654f28a09db31ce886d08bf407aff8a3fb974d91b795960396e77458c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|
Release files / waitmanager_web-0.1.2-py3-none-any.whl
| Download URL | waitmanager_web-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40fdff4e2d01f722be602497bb4ace1751df6a28a17bb51c6343aa16f7a1450c
|
|
BLAKE2b-256 checksum How to use checksums |
8d244185d2374c5bd0e49a8463d19c4cf0e82ddd326103a3cc446fab04b0e5d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|
Security for waitmanager-web 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.