posit-dev / posit-dev/py-shiny

Python 3.12: Shiny refuses to shut down until all network connections are closed

Open
#771 30 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I just installed py-shiny on a fresh Windows installation. I'm getting an issue where any time the shiny app is killed, the terminal freezes. If I run a shiny app with shiny run, then when I press ctrl+C I see messages saying that the shiny app is attempting to shut down, but the terminal gets stuck and never returns to the prompt.

If I run in --reload mode, then the moment I change a file and save it, the terminal gets to the same state.

This happens in the command line and also in VSCode.

(venv) C:\Users\Dean\Documents\R\python\shinytest>shiny run
←[32mINFO←[0m:     Started server process [←[36m16176←[0m]
←[32mINFO←[0m:     Waiting for application startup.
←[32mINFO←[0m:     Application startup complete.
←[32mINFO←[0m:     Uvicorn running on ←[1mhttp://127.0.0.1:8000←[0m (Press CTRL+C to quit)
←[32mINFO←[0m:     127.0.0.1:49687 - "←[1mGET / HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     ('127.0.0.1', 49689) - "WebSocket /websocket/" [accepted]
←[32mINFO←[0m:     connection open
←[32mINFO←[0m:     127.0.0.1:49688 - "←[1mGET / HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     connection closed
←[32mINFO←[0m:     ('127.0.0.1', 49695) - "WebSocket /websocket/" [accepted]
←[32mINFO←[0m:     connection open
←[32mINFO←[0m:     Shutting down

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 shutdown hang with shiny run and --reload on Windows, first with and without an active WebSocket connection. Trace the shutdown sequence around the Uvicorn server and the connection shown in the logs. Done means Ctrl+C and reload return to the terminal prompt without waiting indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.