Skip to Content
Python Microservices Development
book

Python Microservices Development

by Tarek Ziadé
July 2017
Beginner to intermediate
340 pages
7h 43m
English
Packt Publishing
Content preview from Python Microservices Development

Coroutines

To make asynchronous programming more straightforward, the await and async keywords were introduced in Python 3.5, along with the coroutine type. The await call is almost equivalent to yield from, as its goal is to let you call a coroutine from another coroutine.

The difference is that you can't use the await call to call a generator (yet).

The async keyword marks a function, a for or a with loop, as being a native coroutine, and if you try to use that function, you will not retrieve a generator but a coroutine object.

The native coroutine type that was added in Python is like a fully symmetric generator, but all the back and forth is delegated to an event loop, which is in charge of coordinating the execution.

In the example that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Microservices Development - Second Edition

Python Microservices Development - Second Edition

Simon Fraser, Tarek Ziadé
Python Web Development with Sanic

Python Web Development with Sanic

Stephen Sadowski, Adam Hopkins

Publisher Resources

ISBN: 9781785881114Supplemental Content