MCPcopy
hub / github.com/opendevops-cn/opendevops / add_future

Method add_future

scripts/tornado_source_code/tornado/ioloop.py:665–698  ·  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

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