Async for the Python 2 Programmer
By Henry Chen

An exciting new feature in Python 3 is more support for asynchronous programming via the async/await syntax and the asyncio library. However the sheer amount of novelty can be difficult to digest for someone coming from Python 2. To remedy this, we will motivate async with familiar Python 2 concepts and build upon them to arrive at the Python 3 formulation.

Saturday 2:30 p.m.–2:55 p.m.

Background

  • Why async? CPU bound vs IO bound processes.
  • Concurrency is not the same as multithreading
  • Single threaded concurrency

Generators - already in Python 2 !

  • Generator - a function you can pause!
  • How to implement async with generators and event loop in Python 2
  • Real working code - a Python version of the JavaScript setTimeout function

What is new in Python 3 ?

  • async/await - really generators in disguise!
  • asyncio library - ready made event loop and IO functions
  • new syntax and new library are independent - you can mix and match old and new!

Henry Chen

I am an instructor at Hackbright Academy, a Python based full stack engineering bootcamp for women located in San Francisco. Previously, I have worked as a physicist, data scientist, and software engineer.

Sponsors