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

Function multi

python/python3/tornado/gen.py:438–486  ·  view source on GitHub ↗

Runs multiple asynchronous operations in parallel. ``children`` may either be a list or a dict whose values are yieldable objects. ``multi()`` returns a new yieldable object that resolves to a parallel structure containing their results. If ``children`` is a list, the result is a li

(
    children: Union[List[_Yieldable], Dict[Any, _Yieldable]],
    quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (),
)

Source from the content-addressed store, hash-verified

436
437
438def multi(
439 children: Union[List[_Yieldable], Dict[Any, _Yieldable]],
440 quiet_exceptions: "Union[Type[Exception], Tuple[Type[Exception], ...]]" = (),
441) -> "Union[Future[List], Future[Dict]]":
442 """Runs multiple asynchronous operations in parallel.
443
444 ``children`` may either be a list or a dict whose values are
445 yieldable objects. ``multi()`` returns a new yieldable
446 object that resolves to a parallel structure containing their
447 results. If ``children`` is a list, the result is a list of
448 results in the same order; if it is a dict, the result is a dict
449 with the same keys.
450
451 That is, ``results = yield multi(list_of_futures)`` is equivalent
452 to::
453
454 results = []
455 for future in list_of_futures:
456 results.append(yield future)
457
458 If any children raise exceptions, ``multi()`` will raise the first
459 one. All others will be logged, unless they are of types
460 contained in the ``quiet_exceptions`` argument.
461
462 In a ``yield``-based coroutine, it is not normally necessary to
463 call this function directly, since the coroutine runner will
464 do it automatically when a list or dict is yielded. However,
465 it is necessary in ``await``-based coroutines, or to pass
466 the ``quiet_exceptions`` argument.
467
468 This function is available under the names ``multi()`` and ``Multi()``
469 for historical reasons.
470
471 Cancelling a `.Future` returned by ``multi()`` does not cancel its
472 children. `asyncio.gather` is similar to ``multi()``, but it does
473 cancel its children.
474
475 .. versionchanged:: 4.2
476 If multiple yieldables fail, any exceptions after the first
477 (which is raised) will be logged. Added the ``quiet_exceptions``
478 argument to suppress this logging for selected exception types.
479
480 .. versionchanged:: 4.3
481 Replaced the class ``Multi`` and the function ``multi_future``
482 with a unified function ``multi``. Added support for yieldables
483 other than ``YieldPoint`` and `.Future`.
484
485 """
486 return multi_future(children, quiet_exceptions=quiet_exceptions)
487
488
489Multi = multi

Callers 1

convert_yieldedFunction · 0.85

Calls 1

multi_futureFunction · 0.85

Tested by

no test coverage detected