import functools
import asyncio
import traceback


def async_print_exceptions(f):
    """Wraps a coroutine to print exceptions (other than cancellations)."""
    @functools.wraps(f)
    async def wrapper(*args, **kwargs):
        try:
            await f(*args, **kwargs)
        except asyncio.CancelledError:
            raise
        except:
            traceback.print_exc()
            raise
    return wrapper