`pulumi preview` hangs on failure in chained Outputs
### What happened?

With a particular sequence of chained Outputs, a failure can cause `pulumi preview` (or `up`) to hang rather than crash with a traceback.

### Steps to reproduce

```bash
pulumi new aws-python
```

```python
# __main__.py
import pulumi
import pulumi_aws as aws

output = pulumi.Output.from_input("dummy")
# This fails as the given attribute does not exist.
# Removing this line produces a valid configuration
# that succeeds on `pulumi preview`.
output = output.apply(lambda x: x.bad_attribute)

bucket = aws.s3.Bucket("my-bucket", tags={"dummy": output})
# This line is required to induce the failure.
# Removing it causes `pulumi preview` to crash as expected.
bucket = pulumi.Output.from_input(bucket)

aws.s3.Bucket("my-other-bucket", tags={"dummy": bucket.arn})

# This line is required to induce the failure.
# Removing it causes `pulumi preview` to crash as expected.
aws.get_region()
```

```
pulumi preview
```

### Expected Behavior

The preview crashes with a traceback ending in `AttributeError: 'str' object has no attribute 'bad_attribute'`.

### Actual Behavior

The preview hangs indefinitely until killed via Ctrl+C.

### Versions used

```
CLI
Version      3.36.0
Go Version   go1.17.12
Go Compiler  gc

Plugins
NAME    VERSION
aws     5.10.0
python  unknown

Host
OS       Microsoft Windows 10 Pro
Version  10.0.19043 Build 19043
Arch     x86_64

This project is written in python: executable='C:\\Program Files\\Python39\\python.exe' version='3.9.5'

Current Stack: dev

Found no resources associated with dev

Found no pending operations associated with dev

Dependencies:
NAME        VERSION
pip         22.1.2
pulumi-aws  5.10.0
setuptools  63.2.0
wheel       0.37.1
```

### Additional context

_No response_

### Contributing

Vote on this issue by adding a 👍 reaction. 
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already). 

diff --git a/sdk/python/lib/pulumi/runtime/stack.py b/sdk/python/lib/pulumi/runtime/stack.py
index b78924185..2b22ea405 100644
--- a/sdk/python/lib/pulumi/runtime/stack.py
+++ b/sdk/python/lib/pulumi/runtime/stack.py
@@ -67,6 +67,8 @@ async def wait_for_rpcs(await_all_outstanding_tasks=True) -> None:
         # We await each RPC in turn so that this loop will actually block rather than busy-wait.
         while len(RPC_MANAGER.rpcs) > 0:
             await asyncio.sleep(0)
+            if RPC_MANAGER.unhandled_exception is not None:
+                break
             log.debug(
                 f"waiting for quiescence; {len(RPC_MANAGER.rpcs)} RPCs outstanding"
             )
['sdk/python/lib/pulumi/runtime/stack.py']