Description
This workshop will give a high-level overview of tools like multiprocessing, concurrent.futures, the new async and await keywords, and the asyncio library - all of which enable higher performance and nonblocking operation. Attendees will work through simple yet practical examples of their use.
Abstract
Traditionally the concurrency story in Python has not been great: although threads can be trusted to improve the throughput in I/O bound programs, in the standard CPython interpreter the GIL (Global Interpreter Lock) prevents any gains with CPU-bound tasks. This started to change with the multiprocessing module introduced in Python 2.6 and 3.0, which implements nearly the same API as the threading module but using independent processes, thus sidestepping the GIL.
The concurrent.futures package added in Python 3.2 introduced the concept of a Future to represent a pending task, and the very high level Executor API, which lets you easily delegate tasks to threads or processes for asynchronous (i.e. non-blocking) execution.
Then Python 3.3 made it possible to transparently delegate processing from one coroutine to another using the new “yield from” construct. This enables asynchronous programming without callbacks or threads in user-level code, avoiding callback hell, and making multi-step asynchronous algorithms look like simple sequential code. On top of “yield from” and the Future idea, Guido van Rossum built the asyncio library, implementing a pluggable event loop and an asynchronous networking library.
This workshop will give a high-level overview of these tools, showing simple yet practical examples of their use.
Bio
Luciano Ramalho is a Technical Principal at ThoughtWorks and the author of the bestselling book Fluent Python (O'Reilly, 2015). Since 1998 he has deployed Python on some of the largest Web sites in Brazil. His speaking record includes PyCon US, OSCON, OSCON-EU, PythonBrasil, RuPy and an ACM Webinar that was attended by more than 900 people. Ramalho is a fellow of the PSF and co-founder of the Brazilian Python Association and of Garoa Hacker Clube, the first hackerspace in Brazil.