import asyncio
import functools


def bound_concurrency(size):
    """Decorator to limit concurrency on coroutine calls"""
    sem = asyncio.Semaphore(size)
    def decorator(func):
        """Actual decorator"""
        @functools.wraps(func)
        async def wrapper(*args, **kwargs):
            """Wrapper"""
            async with sem:
                return await func(*args, **kwargs)
        return wrapper
    return decorator