Skip to content

Commit

Permalink
Update Python pub_sub sdk example (#889)
Browse files Browse the repository at this point in the history
- Correct the app port in README to make it works again.
- In particular, this fix makes the fastapi example works again.
- The flask example previously still works, due to its code fetchs the app port via the env variable.

Signed-off-by: ZHANG Cheng <[email protected]>
  • Loading branch information
zhangcheng authored Sep 21, 2023
1 parent 6871a0d commit 7b0b832
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions pub_sub/python/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ And one subscriber:

### Run Python message subscriber with Dapr

1. Run the Python subscriber app (flask version) with Dapr:

<!-- STEP
name: run
-->
Expand All @@ -27,8 +29,6 @@ pip3 install -r requirements.txt

<!-- END_STEP -->

2. Run the Python subscriber app with Dapr:

<!-- STEP
name: Run python subscriber
expected_stdout_lines:
Expand All @@ -42,7 +42,38 @@ sleep: 10
-->

```bash
dapr run --app-id order-processor-sdk --resources-path ../../../components/ --app-port 6001 -- uvicorn app:app --port 6002
dapr run --app-id order-processor-sdk --resources-path ../../../components/ --app-port 6002 -- uvicorn app:app --port 6002
```

<!-- END_STEP -->

2. Run the Python subscriber app (fastapi version) with Dapr:

<!-- STEP
name: run
-->

```bash
cd ./order-processor-fastapi
pip3 install -r requirements.txt
```

<!-- END_STEP -->

<!-- STEP
name: Run python subscriber
expected_stdout_lines:
- '== APP == Subscriber received : 4'
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
working_dir: ./order-processor-fastapi
background: true
sleep: 10
-->

```bash
dapr run --app-id order-processor-sdk-fastapi --resources-path ../../../components/ --app-port 6003 -- uvicorn app:app --port 6003
```

<!-- END_STEP -->
Expand All @@ -61,7 +92,7 @@ pip3 install -r requirements.txt
```
<!-- END_STEP -->

3. Run the Python publisher app with Dapr:
2. Run the Python publisher app with Dapr:

<!-- STEP
name: Run python publisher
Expand All @@ -85,4 +116,5 @@ dapr run --app-id checkout-sdk --resources-path ../../../components/ -- python3
```bash
dapr stop --app-id checkout-sdk
dapr stop --app-id order-processor-sdk
dapr stop --app-id order-processor-sdk-fastapi
```

0 comments on commit 7b0b832

Please sign in to comment.