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

Method add_timeout

scripts/tornado_source_code/tornado/ioloop.py:548–587  ·  view source on GitHub ↗

Runs the ``callback`` at the time ``deadline`` from the I/O loop. Returns an opaque handle that may be passed to `remove_timeout` to cancel. ``deadline`` may be a number denoting a time (on the same scale as `IOLoop.time`, normally `time.time`), or a `dateti

(
        self,
        deadline: Union[float, datetime.timedelta],
        callback: Callable[..., None],
        *args: Any,
        **kwargs: Any
    )

Source from the content-addressed store, hash-verified

546 return time.time()
547
548 def add_timeout(
549 self,
550 deadline: Union[float, datetime.timedelta],
551 callback: Callable[..., None],
552 *args: Any,
553 **kwargs: Any
554 ) -> object:
555 """Runs the ``callback`` at the time ``deadline`` from the I/O loop.
556
557 Returns an opaque handle that may be passed to
558 `remove_timeout` to cancel.
559
560 ``deadline`` may be a number denoting a time (on the same
561 scale as `IOLoop.time`, normally `time.time`), or a
562 `datetime.timedelta` object for a deadline relative to the
563 current time. Since Tornado 4.0, `call_later` is a more
564 convenient alternative for the relative case since it does not
565 require a timedelta object.
566
567 Note that it is not safe to call `add_timeout` from other threads.
568 Instead, you must use `add_callback` to transfer control to the
569 `IOLoop`'s thread, and then call `add_timeout` from there.
570
571 Subclasses of IOLoop must implement either `add_timeout` or
572 `call_at`; the default implementations of each will call
573 the other. `call_at` is usually easier to implement, but
574 subclasses that wish to maintain compatibility with Tornado
575 versions prior to 4.0 must use `add_timeout` instead.
576
577 .. versionchanged:: 4.0
578 Now passes through ``*args`` and ``**kwargs`` to the callback.
579 """
580 if isinstance(deadline, numbers.Real):
581 return self.call_at(deadline, callback, *args, **kwargs)
582 elif isinstance(deadline, datetime.timedelta):
583 return self.call_at(
584 self.time() + deadline.total_seconds(), callback, *args, **kwargs
585 )
586 else:
587 raise TypeError("Unsupported deadline %r" % deadline)
588
589 def call_later(
590 self, delay: float, callback: Callable[..., None], *args: Any, **kwargs: Any

Callers 15

run_syncMethod · 0.95
call_atMethod · 0.95
set_timeoutMethod · 0.80
set_connect_timeoutMethod · 0.80
with_timeoutFunction · 0.80
waitMethod · 0.80
_set_timeoutFunction · 0.80
_set_timeoutMethod · 0.80
waitMethod · 0.80
acquireMethod · 0.80
_schedule_nextMethod · 0.80
fetch_implMethod · 0.80

Calls 2

call_atMethod · 0.95
timeMethod · 0.95

Tested by 15

waitMethod · 0.64
test_wait_timeoutMethod · 0.64
test_event_timeoutMethod · 0.64
test_empty_requestMethod · 0.64
tearDownMethod · 0.64