python async io horizon

39
Python Asynchronous I/O asynchronous landscape refresher Photo by Jake Brown used under CC BY 2.0/“Mono+Balance” 19 Dec 2013 @lukmdo

Upload: lukasz-dobrzanski

Post on 08-May-2015

1.384 views

Category:

Technology


4 download

DESCRIPTION

~10min dive to Python Asynchronous IO HTML version (recommended): https://dl.dropboxusercontent.com/u/1565687/speak/Python3%20AsyncIO%20Horizon/index.html

TRANSCRIPT

Page 1: Python Async IO Horizon

Python Asynchronous I/Oasynchronous landscape refresher

Photo by Jake Brown used under CC BY 2.0/“Mono+Balance”

19 Dec 2013 @lukmdo

Page 5: Python Async IO Horizon

PEP index briefPEP Name Status Doc

PEP 255 Simple Generators 2.2 ✔ » »

PEP 342 Coroutines via Enhanced Generators 2.5 ✔ »

PEP 380 Syntax for Delegating to a Subgenerator 3.3 ✔ »

PEP 3148 Futures - execute computations asynchronously 3.2 ✔ »

PEP 3153 Asynchronous IO support 3.3 ✔ »

PEP 3156 Asynchronous IO Support Rebooted: the "asyncio" Module

3.4 ✔ »

Page 22: Python Async IO Horizon

new* old style concurrency

@asyncio.coroutine def update_foo(data, loop): future1 = asyncio.async(run_query1(data)) future2 = asyncio.async(run_query2(data)) ! results = yield from asyncio.gather( future1, future2) data3 = yield from process(*results) yield from run_update_query(data3) ! loop.call_soon(update_cache, data3) ! return ["OK"]

Page 23: Python Async IO Horizon

new* old style concurrency

@asyncio.coroutine def update_foo(data, loop): future1 = asyncio.async(run_query1(data)) future2 = asyncio.async(run_query2(data)) ! results = yield from asyncio.gather( future1, future2) data3 = yield from process(*results) yield from run_update_query(data3) ! loop.call_soon(update_cache, data3) ! return ["OK"]

Page 24: Python Async IO Horizon

new* old style concurrency

@asyncio.coroutine def update_foo(data, loop): future1 = asyncio.async(run_query1(data)) future2 = asyncio.async(run_query2(data)) ! results = yield from asyncio.gather( future1, future2) data3 = yield from process(*results) yield from run_update_query(data3) ! loop.call_soon(update_cache, data3) ! return ["OK"]