Port the code to the new asyncio API