Given an existing context manager, I'd like a function decorator that causes execution to occur inside a with-block.
This should make the following two code blocks equivalent:
@decorate(contextmanager)
async def f():
...
await f()
async def f():
...
async with contextmanager:
await f()
This would be handy for wrapping functions in e.g. asyncio.Semaphore(n) contexts.
Does a convenience utility like decorate already exist somewhere in the standard library?