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

Method wait

python/python3/tornado/locks.py:119–139  ·  view source on GitHub ↗

Wait for `.notify`. Returns a `.Future` that resolves ``True`` if the condition is notified, or ``False`` after a timeout.

(
        self, timeout: Optional[Union[float, datetime.timedelta]] = None
    )

Source from the content-addressed store, hash-verified

117 return result + ">"
118
119 def wait(
120 self, timeout: Optional[Union[float, datetime.timedelta]] = None
121 ) -> Awaitable[bool]:
122 """Wait for `.notify`.
123
124 Returns a `.Future` that resolves ``True`` if the condition is notified,
125 or ``False`` after a timeout.
126 """
127 waiter = Future() # type: Future[bool]
128 self._waiters.append(waiter)
129 if timeout:
130
131 def on_timeout() -> None:
132 if not waiter.done():
133 future_set_result_unless_cancelled(waiter, False)
134 self._garbage_collect()
135
136 io_loop = ioloop.IOLoop.current()
137 timeout_handle = io_loop.add_timeout(timeout, on_timeout)
138 waiter.add_done_callback(lambda _: io_loop.remove_timeout(timeout_handle))
139 return waiter
140
141 def notify(self, n: int = 1) -> None:
142 """Wake ``n`` waiters."""

Callers 12

test_reprMethod · 0.95
test_notifyMethod · 0.95
test_notify_1Method · 0.95
test_notify_nMethod · 0.95
test_notify_allMethod · 0.95
test_wait_timeoutMethod · 0.95
test_nested_notifyMethod · 0.95

Calls 4

currentMethod · 0.80
add_timeoutMethod · 0.80
appendMethod · 0.45
remove_timeoutMethod · 0.45

Tested by 12

test_reprMethod · 0.76
test_notifyMethod · 0.76
test_notify_1Method · 0.76
test_notify_nMethod · 0.76
test_notify_allMethod · 0.76
test_wait_timeoutMethod · 0.76
test_nested_notifyMethod · 0.76