Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

callback_executor-0.0.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

callback_executor-0.0.1-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page