MCPcopy Create free account
hub / github.com/EasyIME/PIME / add_future

Method add_future

python/python3/tornado/ioloop.py:662–695  ·  view source on GitHub ↗

Schedules a callback on the ``IOLoop`` when the given `.Future` is finished. The callback is invoked with one argument, the `.Future`. This method only accepts `.Future` objects and not other awaitables (unlike most of Tornado where the two are inter

(
        self,
        future: "Union[Future[_T], concurrent.futures.Future[_T]]",
        callback: Callable[["Future[_T]"], None],
    )

Source from the content-addressed store, hash-verified

660 self.add_callback(callback, *args, **kwargs)
661
662 def add_future(
663 self,
664 future: "Union[Future[_T], concurrent.futures.Future[_T]]",
665 callback: Callable[["Future[_T]"], None],
666 ) -> None:
667 """Schedules a callback on the ``IOLoop`` when the given
668 `.Future` is finished.
669
670 The callback is invoked with one argument, the
671 `.Future`.
672
673 This method only accepts `.Future` objects and not other
674 awaitables (unlike most of Tornado where the two are
675 interchangeable).
676 """
677 if isinstance(future, Future):
678 # Note that we specifically do not want the inline behavior of
679 # tornado.concurrent.future_add_done_callback. We always want
680 # this callback scheduled on the next IOLoop iteration (which
681 # asyncio.Future always does).
682 #
683 # Wrap the callback in self._run_callback so we control
684 # the error logging (i.e. it goes to tornado.log.app_log
685 # instead of asyncio's log).
686 future.add_done_callback(
687 lambda f: self._run_callback(functools.partial(callback, future))
688 )
689 else:
690 assert is_future(future)
691 # For concurrent futures, we use self.add_callback, so
692 # it's fine if future_add_done_callback inlines that call.
693 future_add_done_callback(
694 future, lambda f: self.add_callback(callback, future)
695 )
696
697 def run_in_executor(
698 self,

Callers 15

runMethod · 0.95
run_in_executorMethod · 0.95
_run_callbackMethod · 0.95
with_timeoutFunction · 0.80
handle_yieldMethod · 0.80
chain_futureFunction · 0.80
_handle_connectionMethod · 0.80
__init__Method · 0.80
start_servingMethod · 0.80
_run_callbackMethod · 0.80
read_messageMethod · 0.80
websocket_connectFunction · 0.80

Calls 4

_run_callbackMethod · 0.95
add_callbackMethod · 0.95
is_futureFunction · 0.90
future_add_done_callbackFunction · 0.90

Tested by 4

test_futureMethod · 0.64
test_future_errorMethod · 0.64
setUpMethod · 0.64