Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
tornadoweb
Tornado
提交
8ecaa437
Tornado
项目概览
镜像
/
tornadoweb
/
Tornado
10 个月 前同步成功
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Tornado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8ecaa437
编写于
9月 28, 2010
作者:
B
Ben Darnell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove references to async_callback from documentation
上级
12218657
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
11 deletion
+4
-11
tornado/web.py
tornado/web.py
+2
-2
website/templates/documentation.txt
website/templates/documentation.txt
+2
-9
未找到文件。
tornado/web.py
浏览文件 @
8ecaa437
...
...
@@ -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
...
...
website/templates/documentation.txt
浏览文件 @
8ecaa437
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录