For a given below co-routine(f),
import csv
import urllib
def f(resp):
print('Line 1')
yield csv.reader(resp.read().decode('utf-8'))
def h():
url = 'http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NYSE&render=download'
resp = urllib.urlopen(url)
cr = f(resp)
cr = f(resp) assigns an iterator object to cr,
cr.next() execute Line 1 and block at yield keyword.
My understanding is, with syntax cr=f(resp) there is no event-loop(task scheduler) with threading, behind the scene
Instead of saying cr=f(resp)(above), If the same function(h) has await f(resp) as mentioned below(await keyword asks for async syntax),
async def h_async():
url = 'http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NYSE&render=download'
resp = urllib.urlopen(url)
await f(resp)
then,
How await f(resp) different from cr=f(resp)?
How h_async() different from h()? Does await keyword introduce event-loop(task scheduler) with threading, behind the scene, as shown in this sample code