2013-10-17 17:40:50 -03:00
|
|
|
"""A Future class similar to the one in PEP 3148."""
|
|
|
|
|
2017-12-10 19:36:12 -04:00
|
|
|
__all__ = (
|
|
|
|
'Future', 'wrap_future', 'isfuture',
|
|
|
|
)
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2016-10-28 13:52:37 -03:00
|
|
|
import concurrent.futures
|
2018-01-22 20:11:18 -04:00
|
|
|
import contextvars
|
2013-10-17 17:40:50 -03:00
|
|
|
import logging
|
2013-12-19 17:42:40 -04:00
|
|
|
import sys
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2016-10-28 13:52:37 -03:00
|
|
|
from . import base_futures
|
2013-10-17 17:40:50 -03:00
|
|
|
from . import events
|
2018-09-11 14:13:04 -03:00
|
|
|
from . import exceptions
|
2017-12-15 01:04:38 -04:00
|
|
|
from . import format_helpers
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
|
2016-10-28 13:52:37 -03:00
|
|
|
isfuture = base_futures.isfuture
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2016-10-28 13:52:37 -03:00
|
|
|
|
|
|
|
_PENDING = base_futures._PENDING
|
|
|
|
_CANCELLED = base_futures._CANCELLED
|
|
|
|
_FINISHED = base_futures._FINISHED
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
|
2016-10-28 13:52:37 -03:00
|
|
|
STACK_DEBUG = logging.DEBUG - 1 # heavy-duty debugging
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
|
|
|
|
class Future:
|
|
|
|
"""This class is *almost* compatible with concurrent.futures.Future.
|
|
|
|
|
|
|
|
Differences:
|
|
|
|
|
2017-11-07 12:03:28 -04:00
|
|
|
- This class is not thread-safe.
|
|
|
|
|
2013-10-17 17:40:50 -03:00
|
|
|
- result() and exception() do not take a timeout argument and
|
|
|
|
raise an exception when the future isn't done yet.
|
|
|
|
|
|
|
|
- Callbacks registered with add_done_callback() are always called
|
2017-11-07 12:03:28 -04:00
|
|
|
via the event loop's call_soon().
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
- This class is not compatible with the wait() and as_completed()
|
|
|
|
methods in the concurrent.futures package.
|
|
|
|
|
|
|
|
(In Python 3.4 or later we may be able to unify the implementations.)
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Class variables serving as defaults for instance variables.
|
|
|
|
_state = _PENDING
|
|
|
|
_result = None
|
|
|
|
_exception = None
|
|
|
|
_loop = None
|
2014-12-04 18:00:13 -04:00
|
|
|
_source_traceback = None
|
2020-05-15 20:55:50 -03:00
|
|
|
_cancel_message = None
|
2020-05-18 02:47:31 -03:00
|
|
|
# A saved CancelledError for later chaining as an exception context.
|
|
|
|
_cancelled_exc = None
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2016-09-09 16:54:54 -03:00
|
|
|
# This field is used for a dual purpose:
|
|
|
|
# - Its presence is a marker to declare that a class implements
|
|
|
|
# the Future protocol (i.e. is intended to be duck-type compatible).
|
|
|
|
# The value must also be not-None, to enable a subclass to declare
|
|
|
|
# that it is not compatible by setting this to None.
|
|
|
|
# - It is set by __iter__() below so that Task._step() can tell
|
2017-12-11 11:35:49 -04:00
|
|
|
# the difference between
|
|
|
|
# `await Future()` or`yield from Future()` (correct) vs.
|
2016-09-09 16:54:54 -03:00
|
|
|
# `yield Future()` (incorrect).
|
|
|
|
_asyncio_future_blocking = False
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2017-12-25 17:16:10 -04:00
|
|
|
__log_traceback = False
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
def __init__(self, *, loop=None):
|
|
|
|
"""Initialize the future.
|
|
|
|
|
2016-02-10 01:44:01 -04:00
|
|
|
The optional event_loop argument allows explicitly setting the event
|
2013-10-17 17:40:50 -03:00
|
|
|
loop object used by the future. If it's not provided, the future uses
|
|
|
|
the default event loop.
|
|
|
|
"""
|
|
|
|
if loop is None:
|
2021-04-25 07:40:44 -03:00
|
|
|
self._loop = events._get_event_loop()
|
2013-10-17 17:40:50 -03:00
|
|
|
else:
|
|
|
|
self._loop = loop
|
|
|
|
self._callbacks = []
|
2014-06-27 08:52:20 -03:00
|
|
|
if self._loop.get_debug():
|
2017-12-15 01:04:38 -04:00
|
|
|
self._source_traceback = format_helpers.extract_stack(
|
|
|
|
sys._getframe(1))
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2016-10-28 13:52:37 -03:00
|
|
|
_repr_info = base_futures._future_repr_info
|
2014-07-29 07:58:23 -03:00
|
|
|
|
|
|
|
def __repr__(self):
|
2017-12-10 19:36:12 -04:00
|
|
|
return '<{} {}>'.format(self.__class__.__name__,
|
|
|
|
' '.join(self._repr_info()))
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2017-04-24 22:57:18 -03:00
|
|
|
def __del__(self):
|
2017-12-25 17:16:10 -04:00
|
|
|
if not self.__log_traceback:
|
2017-04-24 22:57:18 -03:00
|
|
|
# set_exception() was not called, or result() or exception()
|
|
|
|
# has consumed the exception
|
|
|
|
return
|
|
|
|
exc = self._exception
|
|
|
|
context = {
|
2017-12-10 19:36:12 -04:00
|
|
|
'message':
|
|
|
|
f'{self.__class__.__name__} exception was never retrieved',
|
2017-04-24 22:57:18 -03:00
|
|
|
'exception': exc,
|
|
|
|
'future': self,
|
|
|
|
}
|
|
|
|
if self._source_traceback:
|
|
|
|
context['source_traceback'] = self._source_traceback
|
|
|
|
self._loop.call_exception_handler(context)
|
2013-12-19 17:42:40 -04:00
|
|
|
|
2019-12-07 07:05:07 -04:00
|
|
|
def __class_getitem__(cls, type):
|
|
|
|
return cls
|
|
|
|
|
2017-12-25 17:16:10 -04:00
|
|
|
@property
|
|
|
|
def _log_traceback(self):
|
|
|
|
return self.__log_traceback
|
|
|
|
|
|
|
|
@_log_traceback.setter
|
|
|
|
def _log_traceback(self, val):
|
2020-11-28 07:37:08 -04:00
|
|
|
if val:
|
2017-12-25 17:16:10 -04:00
|
|
|
raise ValueError('_log_traceback can only be set to False')
|
|
|
|
self.__log_traceback = False
|
|
|
|
|
2017-12-23 16:04:15 -04:00
|
|
|
def get_loop(self):
|
|
|
|
"""Return the event loop the Future is bound to."""
|
2019-11-13 17:36:46 -04:00
|
|
|
loop = self._loop
|
|
|
|
if loop is None:
|
|
|
|
raise RuntimeError("Future object is not initialized.")
|
|
|
|
return loop
|
2017-12-23 16:04:15 -04:00
|
|
|
|
2020-05-18 02:47:31 -03:00
|
|
|
def _make_cancelled_error(self):
|
|
|
|
"""Create the CancelledError to raise if the Future is cancelled.
|
|
|
|
|
|
|
|
This should only be called once when handling a cancellation since
|
|
|
|
it erases the saved context exception value.
|
|
|
|
"""
|
|
|
|
if self._cancel_message is None:
|
|
|
|
exc = exceptions.CancelledError()
|
|
|
|
else:
|
|
|
|
exc = exceptions.CancelledError(self._cancel_message)
|
|
|
|
exc.__context__ = self._cancelled_exc
|
|
|
|
# Remove the reference since we don't need this anymore.
|
|
|
|
self._cancelled_exc = None
|
|
|
|
return exc
|
|
|
|
|
2020-05-15 20:55:50 -03:00
|
|
|
def cancel(self, msg=None):
|
2013-10-17 17:40:50 -03:00
|
|
|
"""Cancel the future and schedule callbacks.
|
|
|
|
|
|
|
|
If the future is already done or cancelled, return False. Otherwise,
|
|
|
|
change the future's state to cancelled, schedule the callbacks and
|
|
|
|
return True.
|
|
|
|
"""
|
2017-12-25 17:16:10 -04:00
|
|
|
self.__log_traceback = False
|
2013-10-17 17:40:50 -03:00
|
|
|
if self._state != _PENDING:
|
|
|
|
return False
|
|
|
|
self._state = _CANCELLED
|
2020-05-15 20:55:50 -03:00
|
|
|
self._cancel_message = msg
|
2018-01-24 12:31:01 -04:00
|
|
|
self.__schedule_callbacks()
|
2013-10-17 17:40:50 -03:00
|
|
|
return True
|
|
|
|
|
2018-01-24 12:31:01 -04:00
|
|
|
def __schedule_callbacks(self):
|
2013-10-17 17:40:50 -03:00
|
|
|
"""Internal: Ask the event loop to call all callbacks.
|
|
|
|
|
|
|
|
The callbacks are scheduled to be called as soon as possible. Also
|
|
|
|
clears the callback list.
|
|
|
|
"""
|
|
|
|
callbacks = self._callbacks[:]
|
|
|
|
if not callbacks:
|
|
|
|
return
|
|
|
|
|
|
|
|
self._callbacks[:] = []
|
2018-01-22 20:11:18 -04:00
|
|
|
for callback, ctx in callbacks:
|
|
|
|
self._loop.call_soon(callback, self, context=ctx)
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
def cancelled(self):
|
|
|
|
"""Return True if the future was cancelled."""
|
|
|
|
return self._state == _CANCELLED
|
|
|
|
|
|
|
|
# Don't implement running(); see http://bugs.python.org/issue18699
|
|
|
|
|
|
|
|
def done(self):
|
|
|
|
"""Return True if the future is done.
|
|
|
|
|
|
|
|
Done means either that a result / exception are available, or that the
|
|
|
|
future was cancelled.
|
|
|
|
"""
|
|
|
|
return self._state != _PENDING
|
|
|
|
|
|
|
|
def result(self):
|
|
|
|
"""Return the result this future represents.
|
|
|
|
|
|
|
|
If the future has been cancelled, raises CancelledError. If the
|
|
|
|
future's result isn't yet available, raises InvalidStateError. If
|
|
|
|
the future is done and has an exception set, this exception is raised.
|
|
|
|
"""
|
|
|
|
if self._state == _CANCELLED:
|
2020-05-18 02:47:31 -03:00
|
|
|
exc = self._make_cancelled_error()
|
|
|
|
raise exc
|
2013-10-17 17:40:50 -03:00
|
|
|
if self._state != _FINISHED:
|
2018-09-11 14:13:04 -03:00
|
|
|
raise exceptions.InvalidStateError('Result is not ready.')
|
2017-12-25 17:16:10 -04:00
|
|
|
self.__log_traceback = False
|
2013-10-17 17:40:50 -03:00
|
|
|
if self._exception is not None:
|
|
|
|
raise self._exception
|
|
|
|
return self._result
|
|
|
|
|
|
|
|
def exception(self):
|
|
|
|
"""Return the exception that was set on this future.
|
|
|
|
|
|
|
|
The exception (or None if no exception was set) is returned only if
|
|
|
|
the future is done. If the future has been cancelled, raises
|
|
|
|
CancelledError. If the future isn't done yet, raises
|
|
|
|
InvalidStateError.
|
|
|
|
"""
|
|
|
|
if self._state == _CANCELLED:
|
2020-05-18 02:47:31 -03:00
|
|
|
exc = self._make_cancelled_error()
|
|
|
|
raise exc
|
2013-10-17 17:40:50 -03:00
|
|
|
if self._state != _FINISHED:
|
2018-09-11 14:13:04 -03:00
|
|
|
raise exceptions.InvalidStateError('Exception is not set.')
|
2017-12-25 17:16:10 -04:00
|
|
|
self.__log_traceback = False
|
2013-10-17 17:40:50 -03:00
|
|
|
return self._exception
|
|
|
|
|
2018-01-22 20:11:18 -04:00
|
|
|
def add_done_callback(self, fn, *, context=None):
|
2013-10-17 17:40:50 -03:00
|
|
|
"""Add a callback to be run when the future becomes done.
|
|
|
|
|
|
|
|
The callback is called with a single argument - the future object. If
|
|
|
|
the future is already done when this is called, the callback is
|
|
|
|
scheduled with call_soon.
|
|
|
|
"""
|
|
|
|
if self._state != _PENDING:
|
2018-01-22 20:11:18 -04:00
|
|
|
self._loop.call_soon(fn, self, context=context)
|
2013-10-17 17:40:50 -03:00
|
|
|
else:
|
2018-01-22 20:11:18 -04:00
|
|
|
if context is None:
|
|
|
|
context = contextvars.copy_context()
|
|
|
|
self._callbacks.append((fn, context))
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
# New method not in PEP 3148.
|
|
|
|
|
|
|
|
def remove_done_callback(self, fn):
|
|
|
|
"""Remove all instances of a callback from the "call when done" list.
|
|
|
|
|
|
|
|
Returns the number of callbacks removed.
|
|
|
|
"""
|
2018-01-22 20:11:18 -04:00
|
|
|
filtered_callbacks = [(f, ctx)
|
|
|
|
for (f, ctx) in self._callbacks
|
|
|
|
if f != fn]
|
2013-10-17 17:40:50 -03:00
|
|
|
removed_count = len(self._callbacks) - len(filtered_callbacks)
|
|
|
|
if removed_count:
|
|
|
|
self._callbacks[:] = filtered_callbacks
|
|
|
|
return removed_count
|
|
|
|
|
|
|
|
# So-called internal methods (note: no set_running_or_notify_cancel()).
|
|
|
|
|
|
|
|
def set_result(self, result):
|
|
|
|
"""Mark the future done and set its result.
|
|
|
|
|
|
|
|
If the future is already done when this method is called, raises
|
|
|
|
InvalidStateError.
|
|
|
|
"""
|
|
|
|
if self._state != _PENDING:
|
2018-09-11 14:13:04 -03:00
|
|
|
raise exceptions.InvalidStateError(f'{self._state}: {self!r}')
|
2013-10-17 17:40:50 -03:00
|
|
|
self._result = result
|
|
|
|
self._state = _FINISHED
|
2018-01-24 12:31:01 -04:00
|
|
|
self.__schedule_callbacks()
|
2013-10-17 17:40:50 -03:00
|
|
|
|
|
|
|
def set_exception(self, exception):
|
|
|
|
"""Mark the future done and set an exception.
|
|
|
|
|
|
|
|
If the future is already done when this method is called, raises
|
|
|
|
InvalidStateError.
|
|
|
|
"""
|
|
|
|
if self._state != _PENDING:
|
2018-09-11 14:13:04 -03:00
|
|
|
raise exceptions.InvalidStateError(f'{self._state}: {self!r}')
|
2014-01-30 20:01:54 -04:00
|
|
|
if isinstance(exception, type):
|
|
|
|
exception = exception()
|
2016-03-02 12:03:28 -04:00
|
|
|
if type(exception) is StopIteration:
|
|
|
|
raise TypeError("StopIteration interacts badly with generators "
|
|
|
|
"and cannot be raised into a Future")
|
2013-10-17 17:40:50 -03:00
|
|
|
self._exception = exception
|
|
|
|
self._state = _FINISHED
|
2018-01-24 12:31:01 -04:00
|
|
|
self.__schedule_callbacks()
|
2017-12-25 17:16:10 -04:00
|
|
|
self.__log_traceback = True
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2017-12-25 11:48:15 -04:00
|
|
|
def __await__(self):
|
2013-10-17 17:40:50 -03:00
|
|
|
if not self.done():
|
2016-09-09 16:54:54 -03:00
|
|
|
self._asyncio_future_blocking = True
|
2013-10-17 17:40:50 -03:00
|
|
|
yield self # This tells Task to wait for completion.
|
2017-12-25 11:48:15 -04:00
|
|
|
if not self.done():
|
|
|
|
raise RuntimeError("await wasn't used with future")
|
2013-10-17 17:40:50 -03:00
|
|
|
return self.result() # May raise too.
|
|
|
|
|
2017-12-25 11:48:15 -04:00
|
|
|
__iter__ = __await__ # make compatible with 'yield from'.
|
2015-05-11 23:27:25 -03:00
|
|
|
|
2013-10-17 17:40:50 -03:00
|
|
|
|
2016-10-23 23:34:35 -03:00
|
|
|
# Needed for testing purposes.
|
|
|
|
_PyFuture = Future
|
|
|
|
|
|
|
|
|
2017-12-23 16:04:15 -04:00
|
|
|
def _get_loop(fut):
|
|
|
|
# Tries to call Future.get_loop() if it's available.
|
|
|
|
# Otherwise fallbacks to using the old '_loop' property.
|
|
|
|
try:
|
|
|
|
get_loop = fut.get_loop
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
return get_loop()
|
|
|
|
return fut._loop
|
|
|
|
|
|
|
|
|
2015-11-17 13:19:41 -04:00
|
|
|
def _set_result_unless_cancelled(fut, result):
|
|
|
|
"""Helper setting the result only if the future was not cancelled."""
|
|
|
|
if fut.cancelled():
|
|
|
|
return
|
|
|
|
fut.set_result(result)
|
|
|
|
|
|
|
|
|
2018-09-11 14:13:04 -03:00
|
|
|
def _convert_future_exc(exc):
|
|
|
|
exc_class = type(exc)
|
|
|
|
if exc_class is concurrent.futures.CancelledError:
|
|
|
|
return exceptions.CancelledError(*exc.args)
|
|
|
|
elif exc_class is concurrent.futures.TimeoutError:
|
|
|
|
return exceptions.TimeoutError(*exc.args)
|
|
|
|
elif exc_class is concurrent.futures.InvalidStateError:
|
|
|
|
return exceptions.InvalidStateError(*exc.args)
|
|
|
|
else:
|
|
|
|
return exc
|
|
|
|
|
|
|
|
|
2015-10-03 12:31:42 -03:00
|
|
|
def _set_concurrent_future_state(concurrent, source):
|
|
|
|
"""Copy state from a future to a concurrent.futures.Future."""
|
|
|
|
assert source.done()
|
|
|
|
if source.cancelled():
|
|
|
|
concurrent.cancel()
|
|
|
|
if not concurrent.set_running_or_notify_cancel():
|
|
|
|
return
|
|
|
|
exception = source.exception()
|
|
|
|
if exception is not None:
|
2018-09-11 14:13:04 -03:00
|
|
|
concurrent.set_exception(_convert_future_exc(exception))
|
2015-10-03 12:31:42 -03:00
|
|
|
else:
|
|
|
|
result = source.result()
|
|
|
|
concurrent.set_result(result)
|
|
|
|
|
|
|
|
|
2015-11-17 13:19:41 -04:00
|
|
|
def _copy_future_state(source, dest):
|
|
|
|
"""Internal helper to copy state from another Future.
|
|
|
|
|
|
|
|
The other Future may be a concurrent.futures.Future.
|
|
|
|
"""
|
|
|
|
assert source.done()
|
|
|
|
if dest.cancelled():
|
|
|
|
return
|
|
|
|
assert not dest.done()
|
|
|
|
if source.cancelled():
|
|
|
|
dest.cancel()
|
|
|
|
else:
|
|
|
|
exception = source.exception()
|
|
|
|
if exception is not None:
|
2018-09-11 14:13:04 -03:00
|
|
|
dest.set_exception(_convert_future_exc(exception))
|
2015-11-17 13:19:41 -04:00
|
|
|
else:
|
|
|
|
result = source.result()
|
|
|
|
dest.set_result(result)
|
|
|
|
|
|
|
|
|
2015-10-03 12:31:42 -03:00
|
|
|
def _chain_future(source, destination):
|
|
|
|
"""Chain two futures so that when one completes, so does the other.
|
|
|
|
|
|
|
|
The result (or exception) of source will be copied to destination.
|
|
|
|
If destination is cancelled, source gets cancelled too.
|
|
|
|
Compatible with both asyncio.Future and concurrent.futures.Future.
|
|
|
|
"""
|
2016-09-09 18:26:31 -03:00
|
|
|
if not isfuture(source) and not isinstance(source,
|
|
|
|
concurrent.futures.Future):
|
2015-10-03 12:31:42 -03:00
|
|
|
raise TypeError('A future is required for source argument')
|
2016-09-09 18:26:31 -03:00
|
|
|
if not isfuture(destination) and not isinstance(destination,
|
|
|
|
concurrent.futures.Future):
|
2015-10-03 12:31:42 -03:00
|
|
|
raise TypeError('A future is required for destination argument')
|
2017-12-23 16:04:15 -04:00
|
|
|
source_loop = _get_loop(source) if isfuture(source) else None
|
|
|
|
dest_loop = _get_loop(destination) if isfuture(destination) else None
|
2015-10-03 12:31:42 -03:00
|
|
|
|
|
|
|
def _set_state(future, other):
|
2016-09-09 18:26:31 -03:00
|
|
|
if isfuture(future):
|
2015-11-17 13:19:41 -04:00
|
|
|
_copy_future_state(other, future)
|
2015-10-03 12:31:42 -03:00
|
|
|
else:
|
|
|
|
_set_concurrent_future_state(future, other)
|
2013-11-22 15:47:22 -04:00
|
|
|
|
2015-10-03 12:31:42 -03:00
|
|
|
def _call_check_cancel(destination):
|
|
|
|
if destination.cancelled():
|
|
|
|
if source_loop is None or source_loop is dest_loop:
|
|
|
|
source.cancel()
|
|
|
|
else:
|
|
|
|
source_loop.call_soon_threadsafe(source.cancel)
|
2013-11-22 15:47:22 -04:00
|
|
|
|
2015-10-03 12:31:42 -03:00
|
|
|
def _call_set_state(source):
|
2018-05-28 18:10:20 -03:00
|
|
|
if (destination.cancelled() and
|
|
|
|
dest_loop is not None and dest_loop.is_closed()):
|
|
|
|
return
|
2015-10-03 12:31:42 -03:00
|
|
|
if dest_loop is None or dest_loop is source_loop:
|
|
|
|
_set_state(destination, source)
|
|
|
|
else:
|
|
|
|
dest_loop.call_soon_threadsafe(_set_state, destination, source)
|
|
|
|
|
|
|
|
destination.add_done_callback(_call_check_cancel)
|
|
|
|
source.add_done_callback(_call_set_state)
|
|
|
|
|
|
|
|
|
|
|
|
def wrap_future(future, *, loop=None):
|
|
|
|
"""Wrap concurrent.futures.Future object."""
|
2016-09-09 18:26:31 -03:00
|
|
|
if isfuture(future):
|
2015-10-03 12:31:42 -03:00
|
|
|
return future
|
|
|
|
assert isinstance(future, concurrent.futures.Future), \
|
2017-12-10 19:36:12 -04:00
|
|
|
f'concurrent.futures.Future is expected, got {future!r}'
|
2016-05-16 16:38:39 -03:00
|
|
|
if loop is None:
|
2021-04-25 07:40:44 -03:00
|
|
|
loop = events._get_event_loop()
|
2016-05-16 16:38:39 -03:00
|
|
|
new_future = loop.create_future()
|
2015-10-03 12:31:42 -03:00
|
|
|
_chain_future(future, new_future)
|
2013-10-17 17:40:50 -03:00
|
|
|
return new_future
|
2016-10-17 23:48:14 -03:00
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
import _asyncio
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
2016-10-23 23:34:35 -03:00
|
|
|
# _CFuture is needed for tests.
|
|
|
|
Future = _CFuture = _asyncio.Future
|