import asyncio


async def gather_dict(dct):
    """Utility function to do asyncio.gather for dictionaries

    Do asyncio.gather on the dictionary's values, and return the
    dictionary with the futures' results replacing the futures.

    >>> promise = Future()
    >>> promise.set_result("value")
    >>> await gather_dict({"key": promise})
    {"key": "value"}
    """
    items = dct.items()
    results = await asyncio.gather(*(item[1] for item in items))
    keys_results = zip((item[0] for item in items), results)
    return {k: v for k, v in keys_results if v is not None}