Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

I Live-Coded an Async Coroutine Framework in 32.5 Minutes

DZone's Guide to

I Live-Coded an Async Coroutine Framework in 32.5 Minutes

Gain a deep understanding of a miraculous new programming idiom in the Python 3 standard library called "asyncio"

Free Resource

Try RAD Studio for FREE!  It’s the fastest way to develop cross-platform Native Apps with flexible Cloud services and broad IoT connectivity. Start Your Trial Today!

Python 3's "asyncio" module is an efficient async framework similar to Node. But unlike Node, it emphasizes a modern idiom called "coroutines", rather than callbacks. Coroutines promise the best of two worlds: the efficiency of callbacks, but with a natural and robust coding style similar to synchronous programming.

In barely 30 minutes I live-coded a Python 3 async framework at PyGotham 2015. First, I showed how an async framework uses non-blocking sockets, callbacks, and an event loop. This version of the framework is very efficient, but callbacks make a mess of the code. Therefore, I implemented coroutines using Python generators and two classes called Future and Task, and updated my little framework to use coroutines instead of callbacks.

The live-coding demo isn't just a magic trick: watch to see how simply a coroutine-based async framework can be implemented, and gain a deep understanding of this miraculous new programming idiom in the Python 3 standard library.

My mind is blown by the speed and quality of Next Day Video's work at Python conferences. My undying gratitude for this recording of my PyGotham talk.

Get Your Apps to Customers 5X Faster with RAD Studio. Brought to you in partnership with Embarcadero.

Topics:
python ,python 3.0

Published at DZone with permission of A. Jesse Jiryu Davis, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}