Metadata-Version: 2.1
Name: aiothrottler
Version: 0.0.9
Summary: Throttler for asyncio Python
Home-page: https://github.com/michalc/aiothrottler
Author: Michal Charemza
Author-email: michal@charemza.name
License: UNKNOWN
Description: # aiothrottler [![CircleCI](https://circleci.com/gh/michalc/aiothrottler.svg?style=svg)](https://circleci.com/gh/michalc/aiothrottler) [![Test Coverage](https://api.codeclimate.com/v1/badges/e52e294a919c8974c133/test_coverage)](https://codeclimate.com/github/michalc/aiothrottler/test_coverage)
        
        Throttler for asyncio Python
        
        
        ## Installation
        
        ```base
        pip install aiothrottler
        ```
        
        
        ## Example: multiple tasks throttled
        
        ```python
        import asyncio
        import time
        
        from aiothrottler import Throttler
        
        async def main():
            throttler = Throttler(0.5)
            await asyncio.gather(*[
                worker(throttler) for _ in range(10)
            ])
        
        async def worker(throttler):
            await throttler()
            # Interval of at least 0.5 seconds between prints
            # even though all workers started together
            print(time.time())
        
        loop = asyncio.get_event_loop()
        loop.run_until_complete(main())
        loop.close()
        ```
        
        
        ## Example: single task throttled/smoothed
        
        ```python
        import asyncio
        import random
        import time
        
        from aiothrottler import Throttler
        
        async def main():
            throttler = Throttler(0.5)
            for _ in range(10):
                await throttler()
                # Interval of at least 0.5 seconds between prints
                # even though each sleep is random
                print(time.time())
                await asyncio.sleep(random.random())
        
        loop = asyncio.get_event_loop()
        loop.run_until_complete(main())
        loop.close()
        ```
        
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: AsyncIO
Requires-Python: ~=3.5
Description-Content-Type: text/markdown
