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

Method wait

python/python3/tornado/testing.py:351–404  ·  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: Optional[Callable[..., bool]] = None,
        timeout: Optional[float] = None,
    )

Source from the content-addressed store, hash-verified

349 self.__stopped = True
350
351 def wait(
352 self,
353 condition: Optional[Callable[..., bool]] = None,
354 timeout: Optional[float] = None,
355 ) -> Any:
356 """Runs the `.IOLoop` until stop is called or timeout has passed.
357
358 In the event of a timeout, an exception will be thrown. The
359 default timeout is 5 seconds; it may be overridden with a
360 ``timeout`` keyword argument or globally with the
361 ``ASYNC_TEST_TIMEOUT`` environment variable.
362
363 If ``condition`` is not ``None``, the `.IOLoop` will be restarted
364 after `stop()` until ``condition()`` returns ``True``.
365
366 .. versionchanged:: 3.1
367 Added the ``ASYNC_TEST_TIMEOUT`` environment variable.
368
369 .. deprecated:: 5.1
370
371 `stop` and `wait` are deprecated; use ``@gen_test`` instead.
372 """
373 if timeout is None:
374 timeout = get_async_test_timeout()
375
376 if not self.__stopped:
377 if timeout:
378
379 def timeout_func() -> None:
380 try:
381 raise self.failureException(
382 "Async operation timed out after %s seconds" % timeout
383 )
384 except Exception:
385 self.__failure = sys.exc_info()
386 self.stop()
387
388 self.__timeout = self.io_loop.add_timeout(
389 self.io_loop.time() + timeout, timeout_func
390 )
391 while True:
392 self.__running = True
393 self.io_loop.start()
394 if self.__failure is not None or condition is None or condition():
395 break
396 if self.__timeout is not None:
397 self.io_loop.remove_timeout(self.__timeout)
398 self.__timeout = None
399 assert self.__stopped
400 self.__stopped = False
401 self.__rethrow()
402 result = self.__stop_args
403 self.__stop_args = None
404 return result
405
406
407class 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