Skip to content

Instantly share code, notes, and snippets.

View HarryPehkonen's full-sized avatar

Harri Pehkonen HarryPehkonen

View GitHub Profile
@HarryPehkonen
HarryPehkonen / library.py
Last active April 14, 2017 08:52
Writing your own asynchronous library using Tornado. Library.ask is called asynchronously, and just returns a string. Library.check_failure is used to make sure failures are detected when unit-testing.
import tornado.gen
class Library():
@tornado.gen.engine
def ask(self, question, callback=None):
# do a computation that doesn't block for a long time.
result = "Why would you want to know about '{0}'".format(question)
error = None