提交 11399532 编写于 作者: B Ben Darnell

web: Deprecate callback argument to RequestHandler.flush

Also deprecates callback arguments in httputil and http1connection
上级 c60ab672
......@@ -21,6 +21,7 @@
from __future__ import absolute_import, division, print_function
import re
import warnings
from tornado.concurrent import (Future, future_add_done_callback,
future_set_result_unless_cancelled)
......@@ -401,6 +402,8 @@ class HTTP1Connection(httputil.HTTPConnection):
future.exception()
else:
if callback is not None:
warnings.warn("callback argument is deprecated, use returned Future instead",
DeprecationWarning)
self._write_callback = stack_context.wrap(callback)
else:
future = self._write_future = Future()
......@@ -440,6 +443,8 @@ class HTTP1Connection(httputil.HTTPConnection):
self._write_future.exception()
else:
if callback is not None:
warnings.warn("callback argument is deprecated, use returned Future instead",
DeprecationWarning)
self._write_callback = stack_context.wrap(callback)
else:
future = self._write_future = Future()
......
......@@ -591,6 +591,11 @@ class HTTPConnection(object):
The ``version`` field of ``start_line`` is ignored.
Returns a `.Future` if no callback is given.
.. deprecated:: 5.1
The ``callback`` argument is deprecated and will be removed
in Tornado 6.0.
"""
raise NotImplementedError()
......@@ -599,6 +604,11 @@ class HTTPConnection(object):
The callback will be run when the write is complete. If no callback
is given, returns a Future.
.. deprecated:: 5.1
The ``callback`` argument is deprecated and will be removed
in Tornado 6.0.
"""
raise NotImplementedError()
......
......@@ -555,11 +555,13 @@ class FlowControlHandler(RequestHandler):
@asynchronous
def get(self):
self.write("1")
self.flush(callback=self.step2)
with ignore_deprecation():
self.flush(callback=self.step2)
def step2(self):
self.write("2")
self.flush(callback=self.step3)
with ignore_deprecation():
self.flush(callback=self.step3)
def step3(self):
self.write("3")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册