import asyncio async def v(n): for i in range(2): print(n, "Waiting for lock") async with lock: print(n, "Got lock") await f async def test(): f0 = asyncio.ensure_future(v(0)) f1 = asyncio.ensure_future(v(1)) await asyncio.sleep(0) f.set_result(True) f1.cancel() await f0 lock = asyncio.Lock() f = asyncio.Future() loop = asyncio.get_event_loop() loop.run_until_complete(test())