title: Explaining python tornado async
body: <p>So I have been investigating into how to write async code, and i have come up with the code below:</p>
  
  <p>I have the following two questions:</p>
  
  <ol>
  <li>How can we assume this code is async? We are just meant to rely on the fact that using the gen module makes it async( of course we need to write async modules for the gen coroutine)</li>
  <li>Why does tornado incorporate one main thread? can we have a main thread linking to a pool of thread which links to another pool of threads? This question is more towards what do we achieve with one main thread?</li>
  </ol>
  
  
  
  <pre><code>from tornado import gen
  import tornado.web
  import tornado.ioloop
  import motor
  
  class MainHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    @gen.coroutine
    def get(self):
      post = yield db.user.find_one()
      print post
      self.write(post['name'])
  
  handlers=[(
  (r'/', MainHandler)
  )]
  
  db = motor.MotorClient().example
  
  if __name__ == '__main__':
    application = tornado.web.Application(handlers,debug=True)
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
  </code></pre>