Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
tornadoweb
Tornado
提交
c60ab672
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 搜索 >>
提交
c60ab672
编写于
4月 27, 2018
作者:
B
Ben Darnell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
web: Deprecate asynchronous decorator
上级
0200fc85
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
71 addition
and
49 deletion
+71
-49
tornado/test/auth_test.py
tornado/test/auth_test.py
+30
-27
tornado/test/gen_test.py
tornado/test/gen_test.py
+0
-1
tornado/test/httpserver_test.py
tornado/test/httpserver_test.py
+4
-2
tornado/test/simple_httpclient_test.py
tornado/test/simple_httpclient_test.py
+8
-4
tornado/test/stack_context_test.py
tornado/test/stack_context_test.py
+7
-6
tornado/test/web_test.py
tornado/test/web_test.py
+14
-9
tornado/web.py
tornado/web.py
+8
-0
未找到文件。
tornado/test/auth_test.py
浏览文件 @
c60ab672
...
...
@@ -26,17 +26,18 @@ class OpenIdClientLoginHandlerLegacy(RequestHandler, OpenIdMixin):
def
initialize
(
self
,
test
):
self
.
_OPENID_ENDPOINT
=
test
.
get_url
(
'/openid/server/authenticate'
)
@
asynchronous
def
get
(
self
):
if
self
.
get_argument
(
'openid.mode'
,
None
):
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
DeprecationWarning
)
self
.
get_authenticated_user
(
self
.
on_user
,
http_client
=
self
.
settings
[
'http_client'
])
return
res
=
self
.
authenticate_redirect
()
assert
isinstance
(
res
,
Future
)
assert
res
.
done
()
with
ignore_deprecation
():
@
asynchronous
def
get
(
self
):
if
self
.
get_argument
(
'openid.mode'
,
None
):
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
DeprecationWarning
)
self
.
get_authenticated_user
(
self
.
on_user
,
http_client
=
self
.
settings
[
'http_client'
])
return
res
=
self
.
authenticate_redirect
()
assert
isinstance
(
res
,
Future
)
assert
res
.
done
()
def
on_user
(
self
,
user
):
if
user
is
None
:
...
...
@@ -78,16 +79,17 @@ class OAuth1ClientLoginHandlerLegacy(RequestHandler, OAuthMixin):
def
_oauth_consumer_token
(
self
):
return
dict
(
key
=
'asdf'
,
secret
=
'qwer'
)
@
asynchronous
def
get
(
self
):
if
self
.
get_argument
(
'oauth_token'
,
None
):
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
DeprecationWarning
)
self
.
get_authenticated_user
(
self
.
on_user
,
http_client
=
self
.
settings
[
'http_client'
])
return
res
=
self
.
authorize_redirect
(
http_client
=
self
.
settings
[
'http_client'
])
assert
isinstance
(
res
,
Future
)
with
ignore_deprecation
():
@
asynchronous
def
get
(
self
):
if
self
.
get_argument
(
'oauth_token'
,
None
):
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
DeprecationWarning
)
self
.
get_authenticated_user
(
self
.
on_user
,
http_client
=
self
.
settings
[
'http_client'
])
return
res
=
self
.
authorize_redirect
(
http_client
=
self
.
settings
[
'http_client'
])
assert
isinstance
(
res
,
Future
)
def
on_user
(
self
,
user
):
if
user
is
None
:
...
...
@@ -226,12 +228,13 @@ class TwitterClientHandler(RequestHandler, TwitterMixin):
class
TwitterClientLoginHandlerLegacy
(
TwitterClientHandler
):
@
asynchronous
def
get
(
self
):
if
self
.
get_argument
(
"oauth_token"
,
None
):
self
.
get_authenticated_user
(
self
.
on_user
)
return
self
.
authorize_redirect
()
with
ignore_deprecation
():
@
asynchronous
def
get
(
self
):
if
self
.
get_argument
(
"oauth_token"
,
None
):
self
.
get_authenticated_user
(
self
.
on_user
)
return
self
.
authorize_redirect
()
def
on_user
(
self
,
user
):
if
user
is
None
:
...
...
tornado/test/gen_test.py
浏览文件 @
c60ab672
...
...
@@ -1368,7 +1368,6 @@ class GenCoroutineSequenceHandler(RequestHandler):
class
GenCoroutineUnfinishedSequenceHandler
(
RequestHandler
):
@
asynchronous
@
gen
.
coroutine
def
get
(
self
):
yield
gen
.
moment
...
...
tornado/test/httpserver_test.py
浏览文件 @
c60ab672
...
...
@@ -14,7 +14,7 @@ from tornado.netutil import ssl_options_to_context
from
tornado.simple_httpclient
import
SimpleAsyncHTTPClient
from
tornado.testing
import
AsyncHTTPTestCase
,
AsyncHTTPSTestCase
,
AsyncTestCase
,
ExpectLog
,
gen_test
# noqa: E501
from
tornado.test.util
import
unittest
,
skipOnTravis
,
ignore_deprecation
from
tornado.web
import
Application
,
RequestHandler
,
asynchronous
,
stream_request_body
from
tornado.web
import
Application
,
RequestHandler
,
stream_request_body
from
contextlib
import
closing
import
datetime
...
...
@@ -668,9 +668,11 @@ class KeepAliveTest(AsyncHTTPTestCase):
self
.
write
(
''
.
join
(
chr
(
i
%
256
)
*
1024
for
i
in
range
(
512
)))
class
FinishOnCloseHandler
(
RequestHandler
):
@
asynchronous
@
gen
.
coroutine
def
get
(
self
):
self
.
flush
()
never_finish
=
Event
()
yield
never_finish
.
wait
()
def
on_connection_close
(
self
):
# This is not very realistic, but finishing the request
...
...
tornado/test/simple_httpclient_test.py
浏览文件 @
c60ab672
...
...
@@ -17,6 +17,7 @@ from tornado.httpclient import AsyncHTTPClient
from
tornado.httputil
import
HTTPHeaders
,
ResponseStartLine
from
tornado.ioloop
import
IOLoop
from
tornado.iostream
import
UnsatisfiableReadError
from
tornado.locks
import
Event
from
tornado.log
import
gen_log
from
tornado.concurrent
import
Future
from
tornado.netutil
import
Resolver
,
bind_sockets
...
...
@@ -27,7 +28,7 @@ from tornado.testing import (AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCas
ExpectLog
,
gen_test
)
from
tornado.test.util
import
(
skipOnTravis
,
skipIfNoIPv6
,
refusing_port
,
skipBefore35
,
exec_test
,
ignore_deprecation
)
from
tornado.web
import
RequestHandler
,
Application
,
asynchronous
,
url
,
stream_request_body
from
tornado.web
import
RequestHandler
,
Application
,
url
,
stream_request_body
class
SimpleHTTPClientCommonTestCase
(
httpclient_test
.
HTTPClientCommonTestCase
):
...
...
@@ -42,18 +43,21 @@ class TriggerHandler(RequestHandler):
self
.
queue
=
queue
self
.
wake_callback
=
wake_callback
@
asynchronous
@
gen
.
coroutine
def
get
(
self
):
logging
.
debug
(
"queuing trigger"
)
self
.
queue
.
append
(
self
.
finish
)
if
self
.
get_argument
(
"wake"
,
"true"
)
==
"true"
:
self
.
wake_callback
()
never_finish
=
Event
()
yield
never_finish
.
wait
()
class
HangHandler
(
RequestHandler
):
@
asynchronous
@
gen
.
coroutine
def
get
(
self
):
pass
never_finish
=
Event
()
yield
never_finish
.
wait
()
class
ContentLengthHandler
(
RequestHandler
):
...
...
tornado/test/stack_context_test.py
浏览文件 @
c60ab672
...
...
@@ -18,12 +18,13 @@ class TestRequestHandler(RequestHandler):
def
__init__
(
self
,
app
,
request
):
super
(
TestRequestHandler
,
self
).
__init__
(
app
,
request
)
@
asynchronous
def
get
(
self
):
logging
.
debug
(
'in get()'
)
# call self.part2 without a self.async_callback wrapper. Its
# exception should still get thrown
IOLoop
.
current
().
add_callback
(
self
.
part2
)
with
ignore_deprecation
():
@
asynchronous
def
get
(
self
):
logging
.
debug
(
'in get()'
)
# call self.part2 without a self.async_callback wrapper. Its
# exception should still get thrown
IOLoop
.
current
().
add_callback
(
self
.
part2
)
def
part2
(
self
):
logging
.
debug
(
'in part2()'
)
...
...
tornado/test/web_test.py
浏览文件 @
c60ab672
...
...
@@ -8,6 +8,7 @@ from tornado.httputil import format_timestamp
from
tornado.ioloop
import
IOLoop
from
tornado.iostream
import
IOStream
from
tornado
import
locale
from
tornado.locks
import
Event
from
tornado.log
import
app_log
,
gen_log
from
tornado.simple_httpclient
import
SimpleAsyncHTTPClient
from
tornado.template
import
DictLoader
...
...
@@ -369,9 +370,11 @@ class ConnectionCloseHandler(RequestHandler):
def
initialize
(
self
,
test
):
self
.
test
=
test
@
asynchronous
@
gen
.
coroutine
def
get
(
self
):
self
.
test
.
on_handler_waiting
()
never_finish
=
Event
()
yield
never_finish
.
wait
()
def
on_connection_close
(
self
):
self
.
test
.
on_connection_close
()
...
...
@@ -548,10 +551,11 @@ class OptionalPathHandler(RequestHandler):
class
FlowControlHandler
(
RequestHandler
):
# These writes are too small to demonstrate real flow control,
# but at least it shows that the callbacks get run.
@
asynchronous
def
get
(
self
):
self
.
write
(
"1"
)
self
.
flush
(
callback
=
self
.
step2
)
with
ignore_deprecation
():
@
asynchronous
def
get
(
self
):
self
.
write
(
"1"
)
self
.
flush
(
callback
=
self
.
step2
)
def
step2
(
self
):
self
.
write
(
"2"
)
...
...
@@ -1805,10 +1809,11 @@ class MultipleExceptionTest(SimpleHandlerTestCase):
class
Handler
(
RequestHandler
):
exc_count
=
0
@
asynchronous
def
get
(
self
):
IOLoop
.
current
().
add_callback
(
lambda
:
1
/
0
)
IOLoop
.
current
().
add_callback
(
lambda
:
1
/
0
)
with
ignore_deprecation
():
@
asynchronous
def
get
(
self
):
IOLoop
.
current
().
add_callback
(
lambda
:
1
/
0
)
IOLoop
.
current
().
add_callback
(
lambda
:
1
/
0
)
def
log_exception
(
self
,
typ
,
value
,
tb
):
MultipleExceptionTest
.
Handler
.
exc_count
+=
1
...
...
tornado/web.py
浏览文件 @
c60ab672
...
...
@@ -78,6 +78,7 @@ import time
import
tornado
import
traceback
import
types
import
warnings
from
inspect
import
isclass
from
io
import
BytesIO
...
...
@@ -1702,7 +1703,14 @@ def asynchronous(method):
.. versionchanged:: 4.3 Returning anything but ``None`` or a
yieldable object from a method decorated with ``@asynchronous``
is an error. Such return values were previously ignored silently.
.. deprecated:: 5.1
This decorator is deprecated and will be removed in Tornado 6.0.
Use coroutines instead.
"""
warnings
.
warn
(
"@asynchronous is deprecated, use coroutines instead"
,
DeprecationWarning
)
# Delay the IOLoop import because it's not available on app engine.
from
tornado.ioloop
import
IOLoop
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录