import asyncio


lock = asyncio.Lock()


async def task(n):
    global lock
    async with lock: 
        print("task " + str(n) + " got the lock")
        await asyncio.sleep(5)
        
    print("task " + str(n) + " done")


async def main():
    asyncio.get_event_loop().create_task(task(1))
    asyncio.get_event_loop().create_task(task(2))
    

asyncio.get_event_loop().run_until_complete(main())
asyncio.get_event_loop().run_forever()