From 8ecaa43734085ed445ebf7ae70f5be280962e943 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Tue, 28 Sep 2010 15:46:21 -0700 Subject: [PATCH] Remove references to async_callback from documentation --- tornado/web.py | 4 ++-- website/templates/documentation.txt | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tornado/web.py b/tornado/web.py index a5bdb876c..09ea49ab5 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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 diff --git a/website/templates/documentation.txt b/website/templates/documentation.txt index 45cab52a1..a7a58578e 100644 --- a/website/templates/documentation.txt +++ b/website/templates/documentation.txt @@ -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() -- 2.47.2