title: asyncio aiohttp cancel an http request polling, return a result
body: <p>I'm using this code to create an http request every 5 seconds.</p>
  
  <pre><code>async def do_request():
      async with aiohttp.ClientSession() as session:
          async with session.get('http://localhost:8000/') as resp:
              print(resp.status)
              return await resp.text()
  </code></pre>
  
  <p>Didn't find a bulit-in scheduler, so I wrote this function (similar to javascript):</p>
  
  <pre><code>async def set_interval(fn, seconds):
      while True:
          await fn()
          await asyncio.sleep(seconds)
  </code></pre>
  
  <p>And this is how I use it:</p>
  
  <pre><code>asyncio.ensure_future(set_interval(do_request, 5))
  </code></pre>
  
  <p>The code works fine, but I have two requirements:<br>
  1. How can I stop the set_interval after it is added to the event loop? (similar to javascript <code>clearInterval()</code>)<br>
  2. Is it possible that set_interval will return the value of the function that it is wrapping? In this example I will want the response text. Other pattern that will do the same task will be accepted.</p>