Comments (2)
It looks like that error message needs to be fixed.
An explanation of what's happening:
- With Shiny Express apps, the code in the .py file is run once at startup to generate the UI (which is saved and served each time someone connects), and once for each new user session.
- For the first, UI-generating pass, the
shiny.express.session
is not a realSession
object, but instead aExpressMockSession
object. This is the object which throws errors when you try to access the.id
member. - For the user sessions,
shiny.express.session
is aSesssion
object, and accessing members of it will work fine.
I think it would make sense to add a method to ExpressMockSession
and Session
, which reports whether it is a real session object.
For the moment your workaround should be OK. Or you can use this, which is slightly less hacky:
from shiny.session import Session
from shiny.express import session
if isinstance(session, Session):
print("The session ID is:" + str(session.id))
from py-shiny.
In #1331, we added a new method .is_stub_session()
. So with the development version of shiny, you should be able to do:
from shiny.express import session
if not session.is_stub_session():
print("The session ID is:" + str(session.id))
from py-shiny.
Related Issues (20)
- Pulse busy indicator ends prematurely even when the plot hasn't finished loading HOT 3
- Some busy indicators not firing HOT 3
- Automatically enable "clear_button" selectize plugin when `choices` include `""`
- Add CLI command to echo shiny version
- Datagrid selection and filtering may break app HOT 1
- Notifications not showing correctly in Posit Connect
- App with no outputs never stops pulsing HOT 1
- docs(site - data frame): Update examples for v0.11.0
- How to download files using web links and render.download func? HOT 1
- `render.download()` should fail if an exception is thrown
- pip install shiny
- Annoying UX for dropdown menu in `input_selectize`
- fluidPage problem to image detection model HOT 1
- [feature request] improvements to triggering events (such as a button click)
- Proposal: calling a reactive value could be a combined getter/setter
- ui.input_dark_mode not available in version 0.10.1
- Broken link in User Interfaces
- folium maps in py shiny HOT 1
- Not possible to include CSS & Javascript HOT 2
- installing `shiny` via conda does not install `questionary` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py-shiny.