Skip to main content

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

Authors

kanicounter was written by fx-kirin.

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)

Source distribution for kanicounter 0.1.0
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

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page