print function does not get called in an async function before await in python
<p>I want to get some links with requests and asyncio.I have a sample program but I think there is a problem because the print function only gets called when I'm using await.</p>

<p>So why doesn't print gets called where I call the actual function? What I have understood if the await keyword is used, the function interrupts until the future is presentable. In my case, the print function should get called before the await keyword so before the print statement: <code>doing stuff in between</code> or am I wrong?</p>

<pre><code>import asyncio
import requests
import bs4

urls = ["http://www.google.com", "http://www.google.co.uk"]

async def getContent(url):
    loop = asyncio.get_event_loop()
    print("getting content for: " + url) # print should be called here
    # execute a non async function async
    future = loop.run_in_executor(None, requests.get, url)

    # doing stuff with bs4
    soup = bs4.BeautifulSoup((await future).text, "html.parser") # should now interrupt

    return soup 

async def main():
    loop = asyncio.get_event_loop()

    print("starting gathering...")
    # creating a list of futures
    futures = [getContent(url) for url in urls]
    # packing futures into a awaitable list future
    responses_future = asyncio.gather(*futures)

    print("doing stuff in between...")
    # waiting for all futures
    responses = await responses_future

    print("Done")

    for response in responses:
        print(response)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
</code></pre>

<p>output:</p>

<pre><code>starting gathering...
doing stuff in between...
getting content for: http://www.google.com
getting content for: http://www.google.co.uk
Done

HTML CODE HERE!
</code></pre>

<p>Regards</p>