posit-dev / posit-dev/py-shiny
asyncio.exceptions.CancelledError sometimes when stoping pyshiny app via ctrl + c
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
Test steps:
- Install workbench 2022.12.0-daily+286.pro3 on an ec2 instance with the local launcher. I was using ubuntu20
- Create a vs code session.
- Run the following commands in the terminal.
mkdir my-app; cd my-apppython3 -m venv .venv; . .venv/bin/activatepip install --upgrade pippip install shinyshiny create demo_appcd demo_appshiny run --reload- Click the proxy link for the app when it shows in the Posit workbench menu on the left.
- Go back to the terminal and hit ctrl + c
Note: You may need to repeat steps 10-12 a few times to see the error. I have seen this error in VS Code, JupyterLab, and RStudio sessions.
Expected results:
The app should terminate with no issues or errors and the user should see the text Application shutdown complete in the terminal.
Actual results.
asyncio.exceptions.CancelledError sometimes when stoping pyshiny app via ctrl + c. Full error stack below:
(.venv) andrew@ip-172-98-29-238:~/my-app/demo_app$ shiny run --reload
INFO: Will watch for changes in these directories: ['/home/andrew/my-app/demo_app']
INFO: Uvicorn running on https://ec2-34-220-66-81.us-west-2.compute.amazonaws.com/s/038723c9ab5a7a416c856/p/1316efa7/ (Press CTRL+C to quit)
INFO: Started reloader process [25683] using StatReload
INFO: Started server process [25687]
INFO: Waiting for application startup.
INFO: Application startup complete.
^CINFO: Shutting down
INFO: Finished server process [25687]
ERROR: Traceback (most recent call last):
File "/home/andrew/my-app/.venv/lib/python3.9/site-packages/starlette/routing.py", line 674, in lifespan
await receive()
File "/home/andrew/my-app/.venv/lib/python3.9/site-packages/uvicorn/lifespan/on.py", line 137, in receive
return await self.receive_queue.get()
File "/opt/python/3.9.5/lib/python3.9/asyncio/queues.py", line 166, in get
await getter
asyncio.exceptions.CancelledError
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the listed Workbench, Ubuntu, Python, and Shiny steps, especially repeated shiny run --reload stops. Start by reviewing the shutdown paths shown in starlette/routing.py and uvicorn/lifespan/on.py. Done means Ctrl+C consistently terminates the app without an asyncio.exceptions.CancelledError and prints Application shutdown complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100