"async with" in Python 3.4
<p>The Getting Started docs for aiohttp give the following client example:</p>

<pre><code>import asyncio
import aiohttp

async def fetch_page(session, url):
    with aiohttp.Timeout(10):
        async with session.get(url) as response:
            assert response.status == 200
            return await response.read()

loop = asyncio.get_event_loop()
with aiohttp.ClientSession(loop=loop) as session:
    content = loop.run_until_complete(
        fetch_page(session, 'http://python.org'))
    print(content)
</code></pre>

<p>And they give the following note for Python 3.4 users:</p>

<blockquote>
  <p>If you are using Python 3.4, please replace await with yield from and
  async def with a @coroutine decorator.</p>
</blockquote>

<p>If I follow these instructions I get:</p>

<pre><code>import aiohttp
import asyncio

@asyncio.coroutine
def fetch(session, url):
    with aiohttp.Timeout(10):
        async with session.get(url) as response:
            return (yield from response.text())

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    with aiohttp.ClientSession(loop=loop) as session:
        html = loop.run_until_complete(
            fetch(session, 'http://python.org'))
        print(html)
</code></pre>

<p>However, this will not run, because <code>async with</code> is not supported in Python 3.4:</p>

<pre><code>$ python3 client.py 
  File "client.py", line 7
    async with session.get(url) as response:
             ^
SyntaxError: invalid syntax
</code></pre>

<p>How can I translate the <code>async with</code> statement to work with Python 3.4?</p>