From 11399532b96aae6419602e83aba9bdf20f8b93be Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Fri, 27 Apr 2018 10:44:48 -0400 Subject: [PATCH] web: Deprecate callback argument to RequestHandler.flush Also deprecates callback arguments in httputil and http1connection --- tornado/http1connection.py | 5 +++++ tornado/httputil.py | 10 ++++++++++ tornado/test/web_test.py | 6 ++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tornado/http1connection.py b/tornado/http1connection.py index 1c5eadf84..af7abe7c8 100644 --- a/tornado/http1connection.py +++ b/tornado/http1connection.py @@ -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() diff --git a/tornado/httputil.py b/tornado/httputil.py index 9c607b8c8..22a64c311 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -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() diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index b318fb176..a43b4e480 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -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") -- 2.47.2