posit-dev / posit-dev/py-shiny

asyncio.exceptions.CancelledError sometimes when stoping pyshiny app via ctrl + c

Open
#365 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

Test steps:

  1. Install workbench 2022.12.0-daily+286.pro3 on an ec2 instance with the local launcher. I was using ubuntu20
  2. Create a vs code session.
  3. Run the following commands in the terminal.
  4. mkdir my-app; cd my-app
  5. python3 -m venv .venv; . .venv/bin/activate
  6. pip install --upgrade pip
  7. pip install shiny
  8. shiny create demo_app
  9. cd demo_app
  10. shiny run --reload
  11. Click the proxy link for the app when it shows in the Posit workbench menu on the left.
  12. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.