Skip to content

Commit 22cfc8d

Browse files
committed
basic flags example with async/await
1 parent a16bd83 commit 22cfc8d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
*.sublime-project
2+
*.sublime-workspace
13
concurrency/flags/img/*.gif
24
concurrency/charfinder/charfinder_index.pickle
35
18-asyncio/charfinder/charfinder_index.pickle

17-futures/countries/flags_await.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
from flags import BASE_URL, save_flag, show, main # <2>
1818

1919

20-
@asyncio.coroutine # <3>
21-
def get_flag(cc):
20+
async def get_flag(cc): # <3>
2221
url = '{}/{cc}/{cc}.gif'.format(BASE_URL, cc=cc.lower())
23-
resp = yield from aiohttp.request('GET', url) # <4>
24-
image = yield from resp.read() # <5>
22+
resp = await aiohttp.request('GET', url) # <4>
23+
image = await resp.read() # <5>
2524
return image
2625

2726

28-
@asyncio.coroutine
29-
def download_one(cc): # <6>
30-
image = yield from get_flag(cc) # <7>
27+
async def download_one(cc): # <6>
28+
image = await get_flag(cc) # <7>
3129
show(cc)
3230
save_flag(image, cc.lower() + '.gif')
3331
return cc

0 commit comments

Comments
 (0)