Skip to content

Commit

Permalink
Close #163. Don't run widget code if the shiny session is a stub session
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Oct 1, 2024
1 parent cde915c commit 37c7178
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [UNRELEASED]

* Fixed an issue where widgets would sometimes fail to render in a Quarto document. (#159)
* Fixed an issue where importing shinywidgets before a ipywidget implementation can sometimes error in a Shiny Express app. (#163)

## [0.3.3] - 2024-08-13

Expand Down
4 changes: 4 additions & 0 deletions shinywidgets/_shinywidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def init_shiny_widget(w: Widget):
raise RuntimeError(
"shinywidgets requires that all ipywidgets be constructed within an active Shiny session"
)
# Wait until we're in a "real" session before doing anything
# (i.e., on the 1st run of an Express app, it's too early to do anything)
if session.is_stub_session():
return
# Break out of any module-specific session. Otherwise, input.shinywidgets_comm_send
# will be some module-specific copy.
while hasattr(session, "_parent"):
Expand Down

0 comments on commit 37c7178

Please sign in to comment.