atoti.Session.ready#
- property Session.ready: bool#
Whether the session is ready or not.
When
False
, the server will reject most requests made by users without the ROLE_ADMIN role with an HTTP 503 Service Unavailable status. This can be used to prevent queries from being made on a session that has not yet finished its initial setup process (tables and cubes creation, data loading, etc).Note
This property has no impact in the community edition since the ROLE_ADMIN role is always granted.
Example
>>> admin_auth = "admin", "password" >>> user_auth = "user", "password" >>> session_config = tt.SessionConfig(ready=False, security=tt.SecurityConfig()) >>> session = tt.Session.start(session_config) >>> session.ready False >>> for (username, password), roles in { ... admin_auth: {"ROLE_ADMIN"}, ... user_auth: {"ROLE_USER"}, ... }.items(): ... session.security.basic_authentication.credentials[username] = password ... session.security.individual_roles[username] = roles
The session starts as not ready so only admins can access it:
>>> import httpx >>> url = f"{session.url}/{ping_path}" >>> httpx.get(url, auth=admin_auth).status_code 200 >>> httpx.get(url, auth=user_auth).status_code 503
Making the session available to all users:
>>> session.ready = True >>> session.ready True >>> httpx.get(url, auth=admin_auth).status_code 200 >>> httpx.get(url, auth=user_auth).status_code 200
Making the session unavailable to non-admins again:
>>> session.ready = False >>> session.ready False >>> httpx.get(url, auth=admin_auth).status_code 200 >>> httpx.get(url, auth=user_auth).status_code 503
See also
atoti.SessionConfig.ready
to configure the initial value of this property.