Observed since 20 Oct, 18:36 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Sliding-window active request counter (last 60s) using Redis for FastAPI or any Python app.
active_request is a tiny Redis-backed sliding-window counter for tracking live requests in the last N seconds (default 60s). It is safe across multiple processes and works with both sync and async Redis clients (e.g. FastAPI).
pip install active_request
Requires Redis server and
redisPython client ≥ 5.0.
from __future__ import annotations
import os
import redis
from active_request import record_active_request
r = redis.Redis.from_url(os.getenv("REDIS_URL", "redis://localhost:6379/0"))
count = record_active_request(
r,
key="metrics:active_requests:api",
window_seconds=60,
gauge_key="metrics:active_requests:api:count",
)
print(count) # live number of requests in the last 60s
from __future__ import annotations
import os
from fastapi import FastAPI, Depends
from redis.asyncio import Redis
from active_request import arecord_active_request
app = FastAPI()
redis_url = os.getenv("REDIS_URL", "redis://localhost:6379/0")
r = Redis.from_url(redis_url)
@app.get("/ping")
async def ping():
# Increment and get live count of requests in the last 60 seconds
live = await arecord_active_request(
r,
key="metrics:active_requests:api",
window_seconds=60,
gauge_key="metrics:active_requests:api:count",
)
return {"ok": True, "live_60s": live}
record_active_request / arecord_active_request.redis only).Contributions, issues, and feature requests are welcome! Repo: https://github.com/chigwell/active_request • Issues: https://github.com/chigwell/active_request/issues
active_request is licensed under the MIT License.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 2025.9.152128 | 15 Sept 2025 | 1 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 18:36 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:7a9203ab877731167e9945f2fcfba3682941ad50f22a2eef5fd37dba9a0973ca