aio-throttle-to-next-second

Throttler for asyncio Python that throttles to the next whole second, as reported by time.time(). This is useful to force an order on requests to a service that uses a "latest timestamp wins" strategy, such as S3.
Installation
pip install aio-throttle-to-next-second
Usage
Create a shared Throttler, with no arguments
from aio_throttle_to_next_second import Throttler
throttler = Throttler()
and then just before the piece(s) of code to be throttled, call this and await its result.
await throttler()
# Each execution reaching this line will reach this line at a different second
Example: multiple tasks throttled
import asyncio
import time
from aio_throttle_to_next_second import Throttler
async def main():
throttler = Throttler()
await asyncio.gather(*[
worker(throttler) for _ in range(10)
])
async def worker(throttler):
await throttler()
# Each print will show a distinct second, though all workers started together
print(int(time.time()))
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Example: single task throttled
import asyncio
import random
import time
from aio_throttle_to_next_second import Throttler
async def main():
throttler = Throttler()
for _ in range(10):
await throttler()
# Each print will show a distinct second, though there is a random sleep
print(int(time.time()))
await asyncio.sleep(random.random())
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Metadata
Release files for aio-throttle-to-next-second 0.0.1
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 | |
|---|---|---|---|---|
| aio-throttle-to-next-second-0.0.1.tar.gz | 2.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aio_throttle_to_next_second-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.9 kB
Release files / aio-throttle-to-next-second-0.0.1.tar.gz
| Download URL | aio-throttle-to-next-second-0.0.1.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12c7f9832649a3c1b4c27c3e2641662bb5bd63724649bbbeaf1b3a2384277b95
|
|
BLAKE2b-256 checksum How to use checksums |
2d928967cd162a1c97512b9b2310433bd27923c6232a1f8fe2b2cf836d89ccc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / aio_throttle_to_next_second-0.0.1-py3-none-any.whl
| Download URL | aio_throttle_to_next_second-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
289d6f13c2d8e4751446af17a825b075331ddc7f2f16271ee89c643bbc78dc4f
|
|
BLAKE2b-256 checksum How to use checksums |
a01157255c2d93a468b17fd8c1666b4df2c47363e499f9a425ae9a2e7810d5b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for aio-throttle-to-next-second 0.0.1
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.