import functools
import asyncio


def no_block(func):
    """Turns a blocking function into a non-blocking coroutine function."""

    @functools.wraps(func)
    async def no_blocking_handler(*args, **kwargs):
        partial = functools.partial(func, *args, **kwargs)
        return await asyncio.get_event_loop().run_in_executor(None, partial)

    return no_blocking_handler