Skip to content

Commit

Permalink
corrected typo in code snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Kelley committed Feb 23, 2011
1 parent 2d140f4 commit b587e87
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Expand Up @@ -47,12 +47,11 @@ Here's an example with normal callbacks.
class SomeHandler(tornado.web.RequestHandler): class SomeHandler(tornado.web.RequestHandler):
def get(self): def get(self):
self.somedata = 'xxx' self.somedata = 'xxx'
AsyncHTTPClient.fetch( AsyncHTTPClient.fetch( 'http://over/there',
'http://over/there',
callback=self.my_async_http_cb ) callback=self.my_async_http_cb )


def my_async_http_cb(self, fetch_data): def my_async_http_cb(self, fetch_data):
# do stuff here.... # do stuff with fetchdata here
self.write(self.somedata) self.write(self.somedata)




Expand All @@ -64,12 +63,15 @@ Or, you can wrap your methods with async_yield...
@async_yield @async_yield
def get(self): def get(self):
somedata = 'xxx' somedata = 'xxx'
fetchdata = yield AsyncHTTPClient.fetch( fetchdata = yield AsyncHTTPClient.fetch( 'http://over/there',
'http://over/there', callback=self.yield_cb )
callback=self.async_cb ) # do stuff with fetchdata here
self.write(somedata) self.write(somedata)



The @async_yield wrapper doesn't work for every method with callbacks but it The @async_yield wrapper doesn't work for every method with callbacks but it
does cleanup your RequestHandlers quite nicely and really streamlines workflow. does cleanup your RequestHandlers quite nicely and really streamlines workflow.


You begin to see the real power of this when you start to have handlers that make
multiple async calls.


0 comments on commit b587e87

Please sign in to comment.