tornado on davidchua https://dchua.com/tags/tornado/ Recent content in tornado 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. Debugging Websockets with wscat (Websocket CLI Terminal) https://dchua.com/posts/2016-04-01-debugging-websockets-with-wscat/ Fri, 01 Apr 2016 22:32:09 +0800 https://dchua.com/posts/2016-04-01-debugging-websockets-with-wscat/ So I’m currently working on a Websocket implementation from almost-scratch (Tornado/Websockets) and I’m working on implementing some form of rooms/channel functionality. This is mostly just for my learning experience to dive deeper into Python. A cool tool that I’ve just discovered is helping me shave off the time needed to do debugging to a bare minimum. Introducing wscat, a nodejs cli application that allows you to connect directly to a websocket server and receive/send data in a terminal like environment.