Skip to content

Instantly share code, notes, and snippets.

@niran
Created March 28, 2014 19:35
Show Gist options
  • Save niran/9841274 to your computer and use it in GitHub Desktop.
Save niran/9841274 to your computer and use it in GitHub Desktop.
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