This module contains storage support code for handling sessions. Using the SessionStorageRepository one can enumerate sessions at a particular location. Each location is wrapped by a SessionStorage instance. That latter class be used to create (allocate) and remove all of the files associated with a particular session.
Exception raised when SessionStorage.save_checkpoint() finds an existing ‘next’ file from a (presumably) previous call to save_checkpoint() that got interrupted
Abstraction for storage area that is used by SessionState to keep some persistent and volatile data.
This class implements functions performing input/output operations on session checkpoint data. The location property can be used for keeping any additional files or directories but keep in mind that they will be removed by SessionStorage.remove()
This class indirectly collaborates with SessionSuspendHelper and SessionResumeHelper.
Forcibly unlock the storage by removing a file created during atomic filesystem operations of save_checkpoint().
This method might be useful if save_checkpoint() raises LockedStorageError. It removes the “next” file that is used for atomic rename.
Create a new SessionStorage in a random subdirectory of the specified base directory. The base directory is also created if necessary.
Parameters: |
|
---|
Note
Legacy mode is where applications using PlainBox API can only handle one session. Creating another session replaces whatever was stored before. In non-legacy mode applications can enumerate sessions, create arbitrary number of sessions at the same time and remove sessions once they are no longer necessary.
Legacy mode is implemented with a symbolic link called ‘last-session’ that keeps track of the last session created using legacy_mode=True. When a new legacy-mode session is created the target of that symlink is read and recursively removed.
Load checkpoint data from the filesystem
Returns: | data from the most recent checkpoint |
---|---|
Return type: | bytes |
Raises: |
|
Save checkpoint data to the filesystem.
The directory associated with this SessionStorage must already exist. Typically the instance should be obtained by calling SessionStorage.create() which will ensure that this is already the case.
Raises: |
|
---|
Helper class to enumerate filesystem artefacts of current or past Sessions
This class collaborates with SessionStorage. The basic use-case is to open a well-known location and enumerate all the sessions that are stored there. This allows to create SessionStorage instances to further manage each session (such as remove them by calling :meth:SessionStorage.remove()`)
Compute the default location of the session state repository
Returns: | ${XDG_CACHE_HOME:-$HOME/.cache}/plainbox/sessions |
---|
Find the last session storage object created in this repository.
Returns: | SessionStorage object associated with the last session created in this repository using legacy mode. |
---|
Note
This will only return storage objects that were created using legacy mode. Nonlegacy storage objects will not be returned this way.
Enumerate stored sessions in the repository.
If the repository directory is not present then an empty list is returned.
Returns: | list of SessionStorage representing discovered sessions |
---|