From 32f58bf3d7e7e8c024fa15e3d5446f53ee499186 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 22 Apr 2018 00:14:54 -0400 Subject: [PATCH] iostream: Deprecate callback argument to wait_for_handshake --- tornado/iostream.py | 8 ++++++++ tornado/test/iostream_test.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) 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) -- 2.47.2