Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moacirmoda/1095d2807ed3ce149b3918537414b858 to your computer and use it in GitHub Desktop.
Save moacirmoda/1095d2807ed3ce149b3918537414b858 to your computer and use it in GitHub Desktop.
import asyncio
import requests
from datetime import datetime
def get_number(number):
print("%s - %s" % (datetime.now(), number))
response = requests.get("https://httpbin.org/get?number=%s" % number)
async def process(loop):
for number in range(10):
loop.run_in_executor(None, get_number, number)
loop = asyncio.get_event_loop()
loop.run_until_complete(process(loop))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment