提交 8ecaa437 编写于 作者: B Ben Darnell

Remove references to async_callback from documentation

上级 12218657
......@@ -780,9 +780,9 @@ class RequestHandler(object):
return base + static_url_prefix + path
def async_callback(self, callback, *args, **kwargs):
"""Wrap callbacks with this if they are used on asynchronous requests.
"""Obsolete - catches exceptions from the wrapped function.
Catches exceptions and properly finishes the request.
This function is unnecessary since Tornado 1.1.
"""
if callback is None:
return None
......
......@@ -711,7 +711,7 @@ Tornado's built-in asynchronous HTTP client:
def get(self):
http = tornado.httpclient.AsyncHTTPClient()
http.fetch("http://friendfeed-api.com/v2/feed/bret",
callback=self.async_callback(self.on_response))
callback=self.on_response)
def on_response(self, response):
if response.error: raise tornado.web.HTTPError(500)
......@@ -724,13 +724,6 @@ When `get()` returns, the request has not finished. When the HTTP client
eventually calls `on_response()`, the request is still open, and the response
is finally flushed to the client with the call to `self.finish()`.
If you make calls to asynchronous library functions that require a callback
(like the HTTP `fetch` function above), you should always wrap your
callbacks with `self.async_callback`. This simple wrapper ensures that if
your callback function raises an exception or has a programming error,
a proper HTTP error response will be sent to the browser, and the connection
will be properly closed.
For a more advanced asynchronous example, take a look at the `chat` example
application, which implements an AJAX chat room using
[long polling](http://en.wikipedia.org/wiki/Push_technology#Long_polling).
......@@ -755,7 +748,7 @@ the Google credentials in a cookie for later access:
@tornado.web.asynchronous
def get(self):
if self.get_argument("openid.mode", None):
self.get_authenticated_user(self.async_callback(self._on_auth))
self.get_authenticated_user(self._on_auth)
return
self.authenticate_redirect()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册