title: Python 3 aiohttp | Optimize server response time
body: <pre><code>from aiohttp import web
  from aiohttp import ClientSession
  
  # this would go in a different file but keep it simple for now
  class Generate:
  
      # Get a person object from my website
      async def get_person(self):
          async with ClientSession() as session:
              async with session.get('http://surveycodebot.com/person/generate') as response:
                  resp = await response.json()
                  # this prints the person
                  print(resp)
                  return resp
  
      # loops `get_person` to get more than 1 person
      async def get_people(self):
          # array for gathering all responses
          for _ in range(0,10):
              resp = await self.get_person()
          return resp
  
  # class to handle '/'   
  class HomePage(web.View):
      async def get(self):
          # initiate the Generate class and call get_people 
          await Generate().get_people()
          return web.Response(text="Hello, world")
  
  if __name__ == "__main__":
      app = web.Application()
      app.router.add_get('/', HomePage)
      web.run_app(app)
  </code></pre>
  
  <p>Code works and everything is fine. I was wondering why the <code>HomePage</code> takes a while to load. I think I should be using yield on line 28, but it barfs when I do that. Thanks.</p>