From: Ben Darnell Date: Sun, 22 Apr 2018 04:14:54 +0000 (-0400) Subject: iostream: Deprecate callback argument to wait_for_handshake X-Git-Tag: v5.1.0b1~23^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2361%2Fhead;p=thirdparty%2Ftornado.git iostream: Deprecate callback argument to wait_for_handshake --- diff --git a/tornado/iostream.py b/tornado/iostream.py index a302d0eb7..20f481d2a 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -1635,11 +1635,19 @@ class SSLIOStream(IOStream): handshake to complete). It may only be called once per stream. .. versionadded:: 4.2 + + .. deprecated:: 5.1 + + The ``callback`` argument is deprecated and will be removed + in Tornado 6.0. Use the returned `.Future` instead. + """ if (self._ssl_connect_callback is not None or self._ssl_connect_future is not None): raise RuntimeError("Already waiting") if callback is not None: + warnings.warn("callback argument is deprecated, use returned Future instead", + DeprecationWarning) self._ssl_connect_callback = stack_context.wrap(callback) future = None else: diff --git a/tornado/test/iostream_test.py b/tornado/test/iostream_test.py index f12fbc190..cb0967f8c 100644 --- a/tornado/test/iostream_test.py +++ b/tornado/test/iostream_test.py @@ -1215,7 +1215,8 @@ class WaitForHandshakeTest(AsyncTestCase): # The handshake has not yet completed. test.assertIsNone(stream.socket.cipher()) self.stream = stream - stream.wait_for_handshake(self.handshake_done) + with ignore_deprecation(): + stream.wait_for_handshake(self.handshake_done) def handshake_done(self): # Now the handshake is done and ssl information is available. @@ -1250,7 +1251,8 @@ class WaitForHandshakeTest(AsyncTestCase): class TestServer(TCPServer): def handle_stream(self, stream, address): - stream.wait_for_handshake(self.handshake_done) + with ignore_deprecation(): + stream.wait_for_handshake(self.handshake_done) test.assertRaises(RuntimeError, stream.wait_for_handshake) def handshake_done(self): @@ -1266,10 +1268,12 @@ class WaitForHandshakeTest(AsyncTestCase): class TestServer(TCPServer): def handle_stream(self, stream, address): self.stream = stream - stream.wait_for_handshake(self.handshake_done) + with ignore_deprecation(): + stream.wait_for_handshake(self.handshake_done) def handshake_done(self): - self.stream.wait_for_handshake(self.handshake2_done) + with ignore_deprecation(): + self.stream.wait_for_handshake(self.handshake2_done) def handshake2_done(self): handshake_future.set_result(None)