Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoSign in
Socket

aiofreqlimit

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aiofreqlimit - pypi Package Compare versions

Comparing version
0.1.1
to
0.1.3
+37
README.md
# Frequency Limit Context Manager for asyncio
[![Latest PyPI package version](https://badge.fury.io/py/aiofreqlimit.svg)](https://pypi.org/project/aiofreqlimit)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/gleb-chipiga/aiofreqlimit/blob/master/LICENSE)
[![Downloads](https://img.shields.io/pypi/dm/aiofreqlimit)](https://pypistats.org/packages/aiofreqlimit)
## Installation
aiofreqlimit requires Python 3.11 or greater and is available on PyPI. Use pip to install it:
```bash
pip install aiofreqlimit
```
## Using aiofreqlimit
Pass a value of any hashable type to `acquire`, or omit the argument to use the default key:
```python
import asyncio
from aiofreqlimit import FreqLimit
limit = FreqLimit(1 / 10)
async def job():
async with limit.acquire("some_key"):
await some_call()
async def main():
await asyncio.gather(job() for _ in range(100))
asyncio.run(main())
```
from __future__ import annotations
from importlib import metadata
from pathlib import Path
from typing import cast
try:
__version__: str = metadata.version("aiofreqlimit")
except metadata.PackageNotFoundError: # pragma: no cover - local fallback
import tomllib
root = Path(__file__).resolve().parents[1]
pyproject_path = root / "pyproject.toml"
with pyproject_path.open("rb") as pyproject_file:
pyproject: dict[str, object] = tomllib.load(pyproject_file)
project = pyproject.get("project")
if not isinstance(project, dict):
msg = "'project' section missing in pyproject.toml"
raise RuntimeError(msg) from None
project_table = cast(dict[str, object], project)
version_value = project_table.get("version")
if not isinstance(version_value, str):
msg = "'project.version' must be a string in pyproject.toml"
raise RuntimeError(msg) from None
__version__ = version_value
__all__ = ("__version__",)
+23
-33
Metadata-Version: 2.3
Name: aiofreqlimit
Version: 0.1.1
Version: 0.1.3
Summary: Frequency limit for asyncio

@@ -43,50 +43,40 @@ Author: Gleb Chipiga

Project-URL: Homepage, https://github.com/gleb-chipiga/aiofreqlimit
Description-Content-Type: text/x-rst
Description-Content-Type: text/markdown
===========================================
Frequency limit context manager for asyncio
===========================================
# Frequency Limit Context Manager for asyncio
.. image:: https://badge.fury.io/py/aiofreqlimit.svg
:target: https://pypi.org/project/aiofreqlimit
:alt: Latest PyPI package version
[![Latest PyPI package version](https://badge.fury.io/py/aiofreqlimit.svg)](https://pypi.org/project/aiofreqlimit)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/gleb-chipiga/aiofreqlimit/blob/master/LICENSE)
[![Downloads](https://img.shields.io/pypi/dm/aiofreqlimit)](https://pypistats.org/packages/aiofreqlimit)
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://github.com/gleb-chipiga/aiofreqlimit/blob/master/LICENSE
:alt: License
## Installation
.. image:: https://img.shields.io/pypi/dm/aiofreqlimit
:target: https://pypistats.org/packages/aiofreqlimit
:alt: Downloads count
Installation
============
aiofreqlimit requires Python 3.11 or greater and is available on PyPI. Use pip to install it:
.. code-block:: bash
```bash
pip install aiofreqlimit
```
pip install aiofreqlimit
## Using aiofreqlimit
Using aiofreqlimit
==================
Pass a value of any hashable type to `acquire` or do not specify any parameter:
Pass a value of any hashable type to `acquire`, or omit the argument to use the default key:
.. code-block:: python
```python
import asyncio
import asyncio
from aiofreqlimit import FreqLimit
from aiofreqlimit import FreqLimit
limit = FreqLimit(1 / 10)
limit = FreqLimit(1 / 10)
async def job():
async with limit.acquire("some_key"):
await some_call()
async def job():
async with limit.acquire('some_key'):
await some_call()
async def main():
await asyncio.gather(job() for _ in range(100))
async def main():
await asyncio.gather(job() for _ in range(100))
asyncio.run(main())
asyncio.run(main())
```

@@ -7,5 +7,5 @@ [build-system]

name = "aiofreqlimit"
version = "0.1.1"
version = "0.1.3"
description = "Frequency limit for asyncio"
readme = "README.rst"
readme = "README.md"
license = { file = "LICENSE" }

@@ -12,0 +12,0 @@ authors = [{ name = "Gleb Chipiga" }]

@@ -7,4 +7,5 @@ import asyncio

from ._version import __version__
__all__ = ("FreqLimit", "__version__")
__version__ = "0.0.16"

@@ -11,0 +12,0 @@

===========================================
Frequency limit context manager for asyncio
===========================================
.. image:: https://badge.fury.io/py/aiofreqlimit.svg
:target: https://pypi.org/project/aiofreqlimit
:alt: Latest PyPI package version
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://github.com/gleb-chipiga/aiofreqlimit/blob/master/LICENSE
:alt: License
.. image:: https://img.shields.io/pypi/dm/aiofreqlimit
:target: https://pypistats.org/packages/aiofreqlimit
:alt: Downloads count
Installation
============
aiofreqlimit requires Python 3.11 or greater and is available on PyPI. Use pip to install it:
.. code-block:: bash
pip install aiofreqlimit
Using aiofreqlimit
==================
Pass a value of any hashable type to `acquire` or do not specify any parameter:
.. code-block:: python
import asyncio
from aiofreqlimit import FreqLimit
limit = FreqLimit(1 / 10)
async def job():
async with limit.acquire('some_key'):
await some_call()
async def main():
await asyncio.gather(job() for _ in range(100))
asyncio.run(main())