kanicounter is a small Python library for counting events in rolling time windows. It raises an exception when an event exceeds the allowed count.
Usage
from kanicounter import EventCounter, EventLimitError
counter = EventCounter()
counter.add_watch_window(seconds=60, limit=10)
try:
counter.add_event()
except EventLimitError as exc:
print(exc)
limit is the number of events allowed inside the window. For example, seconds=60, limit=10 allows 10 events in the last 60 seconds and raises EventLimitError on the 11th event.
Installation
pip install kanicounter
Requirements
Python 3.8 or newer. There are no runtime dependencies.
Licence
MIT
Metadata
Release files for kanicounter 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kanicounter-0.1.0.tar.gz | 4.6 kB | Details |
Release files / kanicounter-0.1.0.tar.gz
| Download URL | kanicounter-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd8f8ac87de59ef09a87f356bd2b61eaa12fce470fb58bf8aea1f6d93978fb21
|
|
BLAKE2b-256 checksum How to use checksums |
a5854b4afb9ceae6d4fd573688a1f17dc24922633526e4287d8b1fac6dea9a50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|