async on davidchua https://dchua.com/tags/async/ Recent content in async on davidchua Hugo -- gohugo.io en-us Sat, 23 Jul 2016 00:00:00 +0000 How to set current_user in Tornado asynchronously https://dchua.com/posts/2016-07-23-how-to-set-current_user-in-tornado-asynchronously/ Sat, 23 Jul 2016 00:00:00 +0000 https://dchua.com/posts/2016-07-23-how-to-set-current_user-in-tornado-asynchronously/ Something that I’ve missed when working on setting the current_user upon @tornado.web.authenticated. Normally, you’d set get_current_user(self) in the RequestHandler which is used by @tornado.web.authenticated to pull/query the current_user that is logged on. It is fine until you start to utilize asynchronous functions within the get_current_user(self). Quick notes: get_current_user(self) cannot be a coroutine. So no @tornado.gen.coroutine decorator before it. This also means that it cannot perform yield functions from elsewhere. when required to use a async function to pull user information, use prepare(self) instead. Event Loop Tasks https://dchua.com/posts/2016-04-11-event-loop-tasks/ Mon, 11 Apr 2016 00:00:00 +0000 https://dchua.com/posts/2016-04-11-event-loop-tasks/ A pictorial to understanding async loopings Source: Asyncio Task - Python Documentation