A callback queue that execute each callback in a minimum period of time.
Project description
Request Sender
This module provides a CallbackExecutor
class to receive and queue callbacks to
be executed in a defined minimum interval.
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
Built Distribution
Close
Hashes for callback_executor-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2350718ed2ea82e7627833bd0e92a3df0aa12d977fa8313b0671d787bbea409 |
|
MD5 | bdf5363ee5dfc5d30154fbe41fed9d76 |
|
BLAKE2b-256 | c1ef1d0aa373d64844be5d2348d259e8b848be087400f5a6fcb022faada0a754 |