From 4ccfc4c3f7fa7fdf68e4bbd03a0a654c1330a02f Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 4 Jun 2017 20:39:44 -0400 Subject: [PATCH] concurrent: Remove TracebackFuture alias --- docs/concurrent.rst | 2 +- docs/conf.py | 3 --- tornado/auth.py | 4 ++-- tornado/concurrent.py | 12 ++++++------ tornado/gen.py | 12 ++++++------ tornado/httpclient.py | 4 ++-- tornado/ioloop.py | 8 ++++---- tornado/iostream.py | 12 ++++++------ tornado/websocket.py | 6 +++--- 9 files changed, 30 insertions(+), 33 deletions(-) diff --git a/docs/concurrent.rst b/docs/concurrent.rst index 72047811b..049eb6ff7 100644 --- a/docs/concurrent.rst +++ b/docs/concurrent.rst @@ -8,7 +8,7 @@ .. automodule:: tornado.concurrent :members: - :exclude-members: Future, TracebackFuture + :exclude-members: Future .. autoclass:: Future diff --git a/docs/conf.py b/docs/conf.py index 5bc6635b5..e64eb8667 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,9 +39,6 @@ coverage_ignore_modules = [ ] # I wish this could go in a per-module file... coverage_ignore_classes = [ - # tornado.concurrent - "TracebackFuture", - # tornado.gen "Runner", diff --git a/tornado/auth.py b/tornado/auth.py index 93f771bc4..f6d505a20 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -75,7 +75,7 @@ import hmac import time import uuid -from tornado.concurrent import TracebackFuture, return_future, chain_future, future_set_exc_info +from tornado.concurrent import Future, return_future, chain_future, future_set_exc_info from tornado import gen from tornado import httpclient from tornado import escape @@ -117,7 +117,7 @@ def _auth_return_future(f): @functools.wraps(f) def wrapper(*args, **kwargs): - future = TracebackFuture() + future = Future() callback, args, kwargs = replacer.replace(future, args, kwargs) if callback is not None: future.add_done_callback( diff --git a/tornado/concurrent.py b/tornado/concurrent.py index 08c0e0b75..5f723dfed 100644 --- a/tornado/concurrent.py +++ b/tornado/concurrent.py @@ -146,8 +146,6 @@ class Future(object): and ``set_exc_info`` are supported to capture tracebacks in Python 2. The traceback is automatically available in Python 3, but in the Python 2 futures backport this information is discarded. - This functionality was previously available in a separate class - ``TracebackFuture``, which is now a deprecated alias for this class. .. versionchanged:: 4.0 `tornado.concurrent.Future` is always a thread-unsafe ``Future`` @@ -164,6 +162,10 @@ class Future(object): where it results in undesired logging it may be necessary to suppress the logging by ensuring that the exception is observed: ``f.add_done_callback(lambda f: f.exception())``. + + .. versionchanged:: 5.0 + This class was previoiusly available under the name ``TracebackFuture``. + This name, which was deprecated since version 4.0, has been removed. """ def __init__(self): self._done = False @@ -344,8 +346,6 @@ class Future(object): self, ''.join(tb).rstrip()) -TracebackFuture = Future - if futures is None: FUTURES = Future # type: typing.Union[type, typing.Tuple[type, ...]] else: @@ -358,7 +358,7 @@ def is_future(x): class DummyExecutor(object): def submit(self, fn, *args, **kwargs): - future = TracebackFuture() + future = Future() try: future.set_result(fn(*args, **kwargs)) except Exception: @@ -460,7 +460,7 @@ def return_future(f): @functools.wraps(f) def wrapper(*args, **kwargs): - future = TracebackFuture() + future = Future() callback, args, kwargs = replacer.replace( lambda value=_NO_RESULT: future.set_result(value), args, kwargs) diff --git a/tornado/gen.py b/tornado/gen.py index 7368cb67c..92eef367a 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -85,7 +85,7 @@ import textwrap import types import weakref -from tornado.concurrent import Future, TracebackFuture, is_future, chain_future, future_set_exc_info +from tornado.concurrent import Future, is_future, chain_future, future_set_exc_info from tornado.ioloop import IOLoop from tornado.log import app_log from tornado import stack_context @@ -277,7 +277,7 @@ def _make_coroutine_wrapper(func, replace_callback): @functools.wraps(wrapped) def wrapper(*args, **kwargs): - future = TracebackFuture() + future = Future() if replace_callback and 'callback' in kwargs: callback = kwargs.pop('callback') @@ -302,7 +302,7 @@ def _make_coroutine_wrapper(func, replace_callback): orig_stack_contexts = stack_context._state.contexts yielded = next(result) if stack_context._state.contexts is not orig_stack_contexts: - yielded = TracebackFuture() + yielded = Future() yielded.set_exception( stack_context.StackContextInconsistentError( 'stack_context inconsistency (probably caused ' @@ -456,7 +456,7 @@ class WaitIterator(object): Note that this `.Future` will not be the same object as any of the inputs. """ - self._running_future = TracebackFuture() + self._running_future = Future() if self._finished: self._return_result(self._finished.popleft()) @@ -973,7 +973,7 @@ class Runner(object): Maintains information about pending callbacks and their results. The results of the generator are stored in ``result_future`` (a - `.TracebackFuture`) + `.Future`) """ def __init__(self, gen, result_future, first_yielded): self.gen = gen @@ -1104,7 +1104,7 @@ class Runner(object): if isinstance(yielded, YieldPoint): # YieldPoints are too closely coupled to the Runner to go # through the generic convert_yielded mechanism. - self.future = TracebackFuture() + self.future = Future() def start_yield_point(): try: diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 05c62081a..1dea202e5 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -44,7 +44,7 @@ import functools import time import weakref -from tornado.concurrent import TracebackFuture +from tornado.concurrent import Future from tornado.escape import utf8, native_str from tornado import gen, httputil, stack_context from tornado.ioloop import IOLoop @@ -238,7 +238,7 @@ class AsyncHTTPClient(Configurable): # where normal dicts get converted to HTTPHeaders objects. request.headers = httputil.HTTPHeaders(request.headers) request = _RequestProxy(request, self.defaults) - future = TracebackFuture() + future = Future() if callback is not None: callback = stack_context.wrap(callback) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index e64009df6..fd8f369cc 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -44,7 +44,7 @@ import time import traceback import math -from tornado.concurrent import TracebackFuture, is_future, chain_future, future_set_exc_info +from tornado.concurrent import Future, is_future, chain_future, future_set_exc_info from tornado.log import app_log, gen_log from tornado.platform.auto import set_close_exec, Waker from tornado import stack_context @@ -481,13 +481,13 @@ class IOLoop(Configurable): from tornado.gen import convert_yielded result = convert_yielded(result) except Exception: - future_cell[0] = TracebackFuture() + future_cell[0] = Future() future_set_exc_info(future_cell[0], sys.exc_info()) else: if is_future(result): future_cell[0] = result else: - future_cell[0] = TracebackFuture() + future_cell[0] = Future() future_cell[0].set_result(result) self.add_future(future_cell[0], lambda future: self.stop()) self.add_callback(run) @@ -658,7 +658,7 @@ class IOLoop(Configurable): c_future = executor.submit(func, *args) # Concurrent Futures are not usable with await. Wrap this in a # Tornado Future instead, using self.add_future for thread-safety. - t_future = TracebackFuture() + t_future = Future() self.add_future(c_future, lambda f: chain_future(f, t_future)) return t_future diff --git a/tornado/iostream.py b/tornado/iostream.py index 2c2c358c8..cede1f585 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -34,7 +34,7 @@ import socket import sys import re -from tornado.concurrent import TracebackFuture +from tornado.concurrent import Future from tornado import ioloop from tornado.log import gen_log, app_log from tornado.netutil import ssl_wrap_socket, _client_ssl_defaults, _server_ssl_defaults @@ -395,7 +395,7 @@ class BaseIOStream(object): self._write_callback = stack_context.wrap(callback) future = None else: - future = TracebackFuture() + future = Future() future.add_done_callback(lambda f: f.exception()) self._write_futures.append((self._total_write_index, future)) if not self._connecting: @@ -671,7 +671,7 @@ class BaseIOStream(object): if callback is not None: self._read_callback = stack_context.wrap(callback) else: - self._read_future = TracebackFuture() + self._read_future = Future() return self._read_future def _run_read_callback(self, size, streaming): @@ -1091,7 +1091,7 @@ class IOStream(BaseIOStream): self._connect_callback = stack_context.wrap(callback) future = None else: - future = self._connect_future = TracebackFuture() + future = self._connect_future = Future() try: self.socket.connect(address) except socket.error as e: @@ -1169,7 +1169,7 @@ class IOStream(BaseIOStream): orig_close_callback = self._close_callback self._close_callback = None - future = TracebackFuture() + future = Future() ssl_stream = SSLIOStream(socket, ssl_options=ssl_options) # Wrap the original close callback so we can fail our Future as well. # If we had an "unwrap" counterpart to this method we would need @@ -1425,7 +1425,7 @@ class SSLIOStream(IOStream): self._ssl_connect_callback = stack_context.wrap(callback) future = None else: - future = self._ssl_connect_future = TracebackFuture() + future = self._ssl_connect_future = Future() if not self._ssl_accepting: self._run_ssl_connect_callback() return future diff --git a/tornado/websocket.py b/tornado/websocket.py index c6804ca0a..1cc750d9b 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -28,7 +28,7 @@ import tornado.escape import tornado.web import zlib -from tornado.concurrent import TracebackFuture +from tornado.concurrent import Future from tornado.escape import utf8, native_str, to_unicode from tornado import gen, httpclient, httputil from tornado.ioloop import IOLoop, PeriodicCallback @@ -1052,7 +1052,7 @@ class WebSocketClientConnection(simple_httpclient._HTTPConnection): compression_options=None, ping_interval=None, ping_timeout=None, max_message_size=None): self.compression_options = compression_options - self.connect_future = TracebackFuture() + self.connect_future = Future() self.protocol = None self.read_future = None self.read_queue = collections.deque() @@ -1158,7 +1158,7 @@ class WebSocketClientConnection(simple_httpclient._HTTPConnection): ready. """ assert self.read_future is None - future = TracebackFuture() + future = Future() if self.read_queue: future.set_result(self.read_queue.popleft()) else: -- 2.47.2