]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
web: Deprecate callback argument to RequestHandler.flush
authorBen Darnell <ben@bendarnell.com>
Fri, 27 Apr 2018 14:44:48 +0000 (10:44 -0400)
committerBen Darnell <ben@bendarnell.com>
Fri, 27 Apr 2018 14:45:03 +0000 (10:45 -0400)
Also deprecates callback arguments in httputil and http1connection

tornado/http1connection.py
tornado/httputil.py
tornado/test/web_test.py

index 1c5eadf84c41ec0a42e9fd5bd48c9cec212c6d3b..af7abe7c856db0ad59c76c44bebdf84d691239e1 100644 (file)
@@ -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()
index 9c607b8c853aa896c863f0a72cd58683734b79b0..22a64c311bef6dff94926277859d39d861054f65 100644 (file)
@@ -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()
 
index b318fb17622a75d166004bbe6773753ccd571a14..a43b4e48046a6176754889f19f3707df7b6a6d50 100644 (file)
@@ -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")