title: Get current user Async in Tornado
body: <p>When I use <strong>get_current_user(</strong>) I need to check few things in <strong>Redis</strong> (use <strong>tornado-redis</strong>) asynchronously.</p>
  
  <p>I am doing the following:</p>
  
  <pre><code>def authenticated_async(method):
  
      @gen.coroutine
      def wrapper(self, *args, **kwargs):
          self._auto_finish = False
          self.current_user = yield gen.Task(self.get_current_user_async)
          if not self.current_user:
              self.redirect(self.reverse_url('login'))
          else:
              result = method(self, *args, **kwargs) # updates
              if result is not None:
                  yield result
      return wrapper
  
  class BaseClass():
  
      @gen.coroutine
      def get_current_user_async(self,):
  
          auth_cookie = self.get_secure_cookie('user') # cfae7a25-2b8b-46a6-b5c4-0083a114c40e
          user_id = yield gen.Task(c.hget, 'auths', auth_cookie) # 16
          print(123, user_id)
          return auth_cookie if auth_cookie else None
  </code></pre>
  
  <p>For example, I want to use <strong>authenticated_async</strong> decorator:</p>
  
  <pre><code>class IndexPageHandler(BaseClass, RequestHandler):
  
      @authenticated_async
      def get(self):
          self.render("index.html")
  </code></pre>
  
  <p>But I have in console only <strong>123</strong>.</p>
  
  <p>Whats wrong? How to fix that?</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have updated the code with <code>yield result</code>. </p>
  
  <p>In <strong>auth_cookie</strong> I have <code>cfae7a25-2b8b-46a6-b5c4-0083a114c40e</code>.</p>
  
  <p>Then I go to terminal:</p>
  
  <pre><code>127.0.0.1:6379&gt; hget auths cfae7a25-2b8b-46a6-b5c4-0083a114c40e
  "16"
  </code></pre>
  
  <p>So,</p>
  
  <pre><code>user_id = yield gen.Task(c.hget, 'auths', auth_cookie)
  print(123, user_id)
  </code></pre>
  
  <p>Must return </p>
  
  <pre><code>123 16
  </code></pre>
  
  <p>But it returns one 123</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>With</p>
  
  <pre><code>class IndexPageHandler(BaseClass, RequestHandler):
      @gen.coroutine
      def get(self):
          print('cookie', self.get_secure_cookie('user'))
          user_async = yield self.get_current_user_async()
          print('user_async', user_async)
          print('current user', self.current_user)
          self.render("index.html",)
  </code></pre>
  
  <p>In console I have:</p>
  
  <pre><code>cookie b'cfae7a25-2b8b-46a6-b5c4-0083a114c40e'
  123 
  user_async b'cfae7a25-2b8b-46a6-b5c4-0083a114c40e'
  current user None
  </code></pre>