Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions examples/async-requests/asyncio_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Example of using Uplink with aiohttp for non-blocking HTTP requests.
This should work on Python 3.4 and above.
This should work on Python 3.7 and above.
"""
import asyncio
import uplink
Expand All @@ -9,11 +9,10 @@
from github import BASE_URL, GitHub


@asyncio.coroutine
def get_contributors(full_name):
async def get_contributors(full_name):
print("Getting GitHub repository `{}`".format(full_name))
response = yield from gh_async.get_contributors(*full_name.split("/"))
json = yield from response.json()
response = await gh_async.get_contributors(*full_name.split("/"))
json = await response.json()
print("response for {}: {}".format(full_name, json))
return json

Expand All @@ -34,4 +33,4 @@ def get_contributors(full_name):
# Concurrently fetch the contributors for those repositories.
futures = [get_contributors(repo["full_name"]) for repo in repos]
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(futures))
loop.run_until_complete(asyncio.gather(*futures))