# tff.framework.AsyncExecutionContext

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |

An asynchronous execution context backed by an `executor_base.Executor`.

Inherits From: [`AsyncContext`](https://www.tensorflow.org/federated/api_docs/python/tff/framework/AsyncContext)

    tff.framework.AsyncExecutionContext(
        executor_fn: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ExecutorFactory,
        compiler_fn: Optional[Callable[[_Computation], object]] = None,
        *,
        transform_args: Optional[Callable[[object], object]] = None,
        transform_result: Optional[Callable[[object], object]] = None,
        cardinality_inference_fn: cardinalities_utils.CardinalityInferenceFnType = cardinalities_utils.infer_cardinalities
    )

This context's `ingest` and `invoke` methods return Python coroutine objects
which represent the actual work of ingestion and invocation in the backing
executor.

This context will support concurrent invocation of multiple computations if
their arguments have the same cardinalities.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `executor_fn` | Instance of `executor_factory.ExecutorFactory`. |
| `compiler_fn` | A Python function that will be used to compile a computation. |
| `transform_args` | An `Optional` `Callable` used to transform the args before they are passed to the computation. |
| `transform_result` | An `Optional` `Callable` used to transform the result before it is returned. |
| `cardinality_inference_fn` | A Python function specifying how to infer cardinalities from arguments (and their associated types). The value returned by this function will be passed to the `create_executor` method of `executor_fn` to construct a `tff.framework.Executor` instance. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `executor_factory` | <br /> <br /> |

<br />

## Methods

### `invoke`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    invoke(
        comp, arg
    )

Invokes computation `comp` with argument `arg`.

<br />

<br />

<br />

| Args ||
|---|---|
| `comp` | The computation being invoked. The Python type of `comp` expected here (e.g., `pb.Computation`. [`tff.framework.ConcreteComputation`](https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation), or other) may depend on the context. It is the responsibility of the concrete implementation of this interface to verify that the type of `comp` matches what the context is expecting. |
| `arg` | The argument passed to the computation. If no argument is passed, this will be `None`. Structural argument types will be normalized into [`tff.structure.Struct`](https://www.tensorflow.org/federated/api_docs/python/tff/structure/Struct)s. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The result of invocation, which is context-dependent. ||

<br />