Saturday 3 p.m.–4:50 p.m.

A brief introduction to concurrency and coroutines (Tutorial)

Eric Appelt

Audience level:
Novice

Description

This tutorial will introduce concurrency through python coroutines. Using a simple "slow" web service for an example, we will explore writing a client to perform concurrent requests, and then how to write the example service itself. The tutorial will also consider the purpose of concurrent programming, how concurrency differs from parallelism, and will discuss python syntax for coroutines.

Abstract

This is a beginner-friendly introduction to concurrent programming using python coroutines and the standard library asyncio module. The tutorial will first cover the meaning of concurrent programming and how it differs from parallelism. It will then continue to explore the syntax introduced in python 3.5: coroutine definitions, await expressions, async for statements, and async with statements. The need for a framework with a scheduler or event loop will be discussed, with the standard library asyncio package used as an example for the tutorial.

A simple slow web service will be introduced as an example for understanding how to use coroutines. We will write a simple client to make several requests in sequence, and then use the aiohttp library to rewrite it using coroutines to make concurrent requests. Time permitting, we will also look at rewriting the web service itself to use coroutines to handle multiple requests concurrently.

It will be assumed that the listener has a basic understanding of functions, classes, and exceptions in Python, but no prior knowledge of concurrent programming is required.

Setup Instructions

https://github.com/appeltel/CoroutineTutorial#setup-instructions