A callback queue that execute each callback in a configured interval between calls.
Project description
Request Sender
This module provides a CallbackExecutor
class to receive and queue callbacks to
be executed in a configured interval between calls.
The time between calls can be greater than the configured interval, but not less.
Use Case
If one needs to limit the rate of request to an API endpoint.
Sample Code
import asyncio
from callback_executor import ExecutorQueue
async main():
exec_queue = ExecutorQueue(call_interval=0.5)
await exec_queue.ready()
tasks = [
exec_queue.enqueue_callback(blocking_request_to_api_1),
exec_queue.enqueue_callback(blocking_request_to_api_2),
]
responses = await asyncio.gather(*tasks)
# Handle responses
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file callback_executor-0.0.2.tar.gz
.
File metadata
- Download URL: callback_executor-0.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4799cbd924b33f00aa0f7942f92523a268653b6a6e18ceee5eeb3ec74c2e0424 |
|
MD5 | 6edadcb7a857dcbe7735229342d8d004 |
|
BLAKE2b-256 | 51e1b7f9e479abc9832d5a50118cc4df9eba4443b1ab1904d188191bb041ca55 |