Andrew Godwin / @andrewgodwin Hi, I’m Andrew Godwin • Django core developer • Worked on Migrations, Channels & Async • Once a Londoner, now from Denver, USA
Andrew Godwin / @andrewgodwin # Ready when a timer finishes await asyncio.sleep(1) # Ready when network packets return await client.get("http://example.com") # Ready when the coroutine exits await my_function("hello", 64.2)
Andrew Godwin / @andrewgodwin async def calculate(x): result = await coroutine(x) return result # These both return a coroutine def calculate(x): result = coroutine(x) return result
Andrew Godwin / @andrewgodwin # Calls get.__call__ instance = MyModel.objects.get(id=3) # Calls get.__call__ # and then awaits its result instance = await MyModel.objects.get(id=3)