jupyter_server.services.sessions package#
Submodules#
Tornado handlers for the sessions web service.
Preliminary documentation at ipython/ipython
- class jupyter_server.services.sessions.handlers.SessionHandler(application, request, **kwargs)#
Bases:
SessionsAPIHandler
A handler for a single session.
- delete(session_id)#
Delete the session with given session_id.
- get(session_id)#
Get the JSON model for a single session.
- patch(session_id)#
Patch updates sessions:
path updates session to track renamed paths
kernel.name starts a new kernel with a given kernelspec
- class jupyter_server.services.sessions.handlers.SessionRootHandler(application, request, **kwargs)#
Bases:
SessionsAPIHandler
A Session Root API handler.
- get()#
Get a list of running sessions.
- post()#
Create a new session.
- class jupyter_server.services.sessions.handlers.SessionsAPIHandler(application, request, **kwargs)#
Bases:
APIHandler
A Sessions API handler.
- auth_resource = 'sessions'#
A base class session manager.
- class jupyter_server.services.sessions.sessionmanager.KernelSessionRecord(session_id=None, kernel_id=None)#
Bases:
object
A record object for tracking a Jupyter Server Kernel Session.
Two records that share a session_id must also share a kernel_id, while kernels can have multiple session (and thereby) session_ids associated with them.
- exception jupyter_server.services.sessions.sessionmanager.KernelSessionRecordConflict#
Bases:
Exception
Exception class to use when two KernelSessionRecords cannot merge because of conflicting data.
- class jupyter_server.services.sessions.sessionmanager.KernelSessionRecordList(*records)#
Bases:
object
An object for storing and managing a list of KernelSessionRecords.
When adding a record to the list, the KernelSessionRecordList first checks if the record already exists in the list. If it does, the record will be updated with the new information; otherwise, it will be appended.
- get(record)#
Return a full KernelSessionRecord from a session_id, kernel_id, or incomplete KernelSessionRecord.
- Return type:
- remove(record)#
Remove a record if its found in the list. If it’s not found, do nothing.
- Return type:
- class jupyter_server.services.sessions.sessionmanager.SessionManager(**kwargs: Any)#
Bases:
LoggingConfigurable
A session manager.
- close()#
Close the sqlite connection
- property connection#
Start a database connection
- contents_manager#
A trait whose value must be an instance of a class in a specified list of classes. The value can also be an instance of a subclass of the specified classes. Subclasses can declare default classes by overriding the klass attribute
- async create_session(path=None, name=None, type=None, kernel_name=None, kernel_id=None)#
Creates a session and returns its model
- property cursor#
Start a cursor and create a database called ‘session’
- database_filepath#
` setting from sqlite3) and does not persist when the current Jupyter Server shuts down.
- Type:
The filesystem path to SQLite Database file (e.g. /path/to/session_database.db). By default, the session database is stored in-memory (i.e. `
- Type:
memory
- async delete_session(session_id)#
Deletes the row in the session database with given session_id
- get_kernel_env(path, name=None)#
Return the environment variables that need to be set in the kernel
- async get_session(**kwargs)#
Returns the model for a particular session.
Takes a keyword argument and searches for the value in the session database, then returns the rest of the session’s info.
- async kernel_culled(kernel_id)#
Checks if the kernel is still considered alive and returns true if its not found.
- Return type:
- kernel_manager#
A trait whose value must be an instance of a specified class.
The value can also be an instance of a subclass of the specified class.
Subclasses can declare default classes by overriding the klass attribute
- async list_sessions()#
Returns a list of dictionaries containing all the information from the session database
- async row_to_model(row, tolerate_culled=False)#
Takes sqlite database session row and turns it into a dictionary
- async save_session(session_id, path=None, name=None, type=None, kernel_id=None)#
Saves the items for the session with the given session_id
Given a session_id (and any other of the arguments), this method creates a row in the sqlite session database that holds the information for a session.
- Parameters:
- Returns:
model – a dictionary of the session model
- Return type:
- async session_exists(path)#
Check to see if the session of a given name exists
- async start_kernel_for_session(session_id, path, name, type, kernel_name)#
Start a new kernel for a given session.
- Parameters:
session_id (str) – uuid for the session; this method must be given a session_id
path (str) – the path for the given session - seem to be a session id sometime.
name (str) – Usually the model name, like the filename associated with current kernel.
type (str) – the type of the session
kernel_name (str) – the name of the kernel specification to use. The default kernel name will be used if not provided.
- Return type:
- async update_session(session_id, **kwargs)#
Updates the values in the session database.
Changes the values of the session with the given session_id with the values from the keyword arguments.