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

Method wait

scripts/tornado_source_code/tornado/testing.py:290–341  ·  view source on GitHub ↗

Runs the `.IOLoop` until stop is called or timeout has passed. In the event of a timeout, an exception will be thrown. The default timeout is 5 seconds; it may be overridden with a ``timeout`` keyword argument or globally with the ``ASYNC_TEST_TIMEOUT`` environment v

(
        self, condition: Callable[..., bool] = None, timeout: float = None
    )

Source from the content-addressed store, hash-verified

288 self.__stopped = True
289
290 def wait(
291 self, condition: Callable[..., bool] = None, timeout: float = None
292 ) -> None:
293 """Runs the `.IOLoop` until stop is called or timeout has passed.
294
295 In the event of a timeout, an exception will be thrown. The
296 default timeout is 5 seconds; it may be overridden with a
297 ``timeout`` keyword argument or globally with the
298 ``ASYNC_TEST_TIMEOUT`` environment variable.
299
300 If ``condition`` is not ``None``, the `.IOLoop` will be restarted
301 after `stop()` until ``condition()`` returns ``True``.
302
303 .. versionchanged:: 3.1
304 Added the ``ASYNC_TEST_TIMEOUT`` environment variable.
305
306 .. deprecated:: 5.1
307
308 `stop` and `wait` are deprecated; use ``@gen_test`` instead.
309 """
310 if timeout is None:
311 timeout = get_async_test_timeout()
312
313 if not self.__stopped:
314 if timeout:
315
316 def timeout_func() -> None:
317 try:
318 raise self.failureException(
319 "Async operation timed out after %s seconds" % timeout
320 )
321 except Exception:
322 self.__failure = sys.exc_info()
323 self.stop()
324
325 self.__timeout = self.io_loop.add_timeout(
326 self.io_loop.time() + timeout, timeout_func
327 )
328 while True:
329 self.__running = True
330 self.io_loop.start()
331 if self.__failure is not None or condition is None or condition():
332 break
333 if self.__timeout is not None:
334 self.io_loop.remove_timeout(self.__timeout)
335 self.__timeout = None
336 assert self.__stopped
337 self.__stopped = False
338 self.__rethrow()
339 result = self.__stop_args
340 self.__stop_args = None
341 return result
342
343
344class AsyncHTTPTestCase(AsyncTestCase):

Callers 1

tearDownMethod · 0.45

Calls 6

__rethrowMethod · 0.95
get_async_test_timeoutFunction · 0.85
add_timeoutMethod · 0.80
timeMethod · 0.80
startMethod · 0.45
remove_timeoutMethod · 0.45

Tested by

no test coverage detected