Created
March 28, 2014 19:35
-
-
Save niran/9841274 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import time | |
from tornado import gen | |
from tornado.web import RequestHandler | |
def get_data(id): | |
time.sleep(3) | |
data = {'hello': 'world'} | |
return data | |
class ExampleHandler(RequestHandler): | |
@gen.coroutine | |
def get(self, id): | |
print 'Request started' | |
data = yield self.application.executor.submit(get_data, id) | |
self.write(json.dumps(data)) | |
self.finish() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment