# tf_agents.environments.parallel_py_environment.ProcessPyEnvironment

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L230-L503) |

Step a single env in a separate process for lock free paralellism.

    tf_agents.environments.parallel_py_environment.ProcessPyEnvironment(
        env_constructor: https://www.tensorflow.org/agents/api_docs/python/tf_agents/environments/parallel_py_environment/EnvConstructor,
        flatten: bool = False
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `env_constructor` | Callable that creates and returns a Python environment. |
| `flatten` | Boolean, whether to assume flattened actions and time_steps during communication to avoid overhead. |

<br />

## Methods

### `access`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L351-L363)

    access(
        name: Text
    ) -> Any

Access an attribute of the external environment.

This method blocks.

<br />

<br />

<br />

| Args ||
|---|---|
| `name` | Name of the attribute to access. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The attribute value. ||

<br />

### `action_spec`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L298-L301)

    action_spec() -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/NestedArraySpec

### `call`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L336-L349)

    call(
        name: Text, *args, **kwargs
    ) -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/environments/parallel_py_environment/Promise

Asynchronously call a method of the external environment.

<br />

<br />

<br />

| Args ||
|---|---|
| `name` | Name of the method to call. |
| `*args` | Positional arguments to forward to the method. |
| `**kwargs` | Keyword arguments to forward to the method. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The attribute. ||

<br />

### `close`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L365-L374)

    close() -> None

Send a close message to the external process and join it.

### `observation_spec`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L293-L296)

    observation_spec() -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/NestedArraySpec

### `render`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L410-L434)

    render(
        mode: Text = 'rgb_array', blocking: bool = True
    ) -> Union[types.NestedArray, Promise]

Renders the environment.

<br />

<br />

<br />

| Args ||
|---|---|
| `mode` | Rendering mode. Only 'rgb_array' is supported. |
| `blocking` | Whether to wait for the result. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| An ndarray of shape \[width, height, 3\] denoting an RGB image when blocking. Otherwise, callable that returns the rendered image. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `NotImplementedError` | If the environment does not support rendering, or any other modes than `rgb_array` is given. |

<br />

### `reset`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L394-L408)

    reset(
        blocking: bool = True
    ) -> Union[https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep, https://www.tensorflow.org/agents/api_docs/python/tf_agents/environments/parallel_py_environment/Promise]

Reset the environment.

<br />

<br />

<br />

| Args ||
|---|---|
| `blocking` | Whether to wait for the result. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| New observation when blocking, otherwise callable that returns the new observation. ||

<br />

### `start`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L270-L282)

    start(
        wait_to_start: bool = True
    ) -> None

Start the process.

<br />

<br />

<br />

| Args ||
|---|---|
| `wait_to_start` | Whether the call should wait for an env initialization. |

<br />

### `step`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L376-L392)

    step(
        action: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/NestedArray,
        blocking: bool = True
    ) -> Union[https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep, https://www.tensorflow.org/agents/api_docs/python/tf_agents/environments/parallel_py_environment/Promise]

Step the environment.

<br />

<br />

<br />

| Args ||
|---|---|
| `action` | The action to apply to the environment. |
| `blocking` | Whether to wait for the result. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| time step when blocking, otherwise callable that returns the time step. ||

<br />

### `time_step_spec`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L303-L306)

    time_step_spec() -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/trajectories/TimeStep

### `wait_start`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/environments/parallel_py_environment.py#L284-L291)

    wait_start() -> None

Wait for the started process to finish initialization.