plainbox.impl.session.manager – manager for sessions

This module contains glue code that allows one to create and manage sessions and their filesystem presence. It allows SessionState to be de-coupled from SessionStorageRepository, SessionStorage, SessionSuspendHelper and SessionResumeHelper.

class plainbox.impl.session.manager.SessionManager(state, storage)[source]

Manager class for coupling SessionStorage with SessionState.

This class allows application code to manage disk state of sessions. Using the checkpoint() method applications can create persistent snapshots of the SessionState associated with each SessionManager.

checkpoint()[source]

Create a checkpoint of the session.

After calling this method you can later reopen the same session with SessionManager.open_session().

classmethod create_session(job_list=None, repo=None, legacy_mode=False)[source]

Create a session manager with a fresh session.

This method populates the session storage with all of the well known directories (using WellKnownDirsHelper.populate())

Parameters:
  • job_list – If specified then this will be the initial list of jobs known by the session state object. This can be specified for convenience but is really optional since the application can always add more jobs to an existing session.
  • repo – If specified then this particular repository will be used to create the storage for this session. If left out, a new repository is constructed with the default location.
  • legacy_mode – Propagated to create() to ensure that legacy (single session) mode is used.
Ptype job_list:

list of IJobDefinition.

Ptype repo:

SessionStorageRepository.

Ptype legacy_mode:
 

bool

Returns:

fresh SessionManager instance

destroy()[source]

Destroy all of the filesystem artifacts of the session.

This basically calls remove()

classmethod load_session(job_list, storage, early_cb=None)[source]

Load a previously checkpointed session.

This method allows one to re-open a session that was previously created by SessionManager.checkpoint()

Parameters:
  • job_list – List of all known jobs. This argument is used to reconstruct the session from a dormant state. Since the suspended data cannot capture implementation details of each job reliably actual jobs need to be provided externally. Unlike in create_session() this list really needs to be complete, it must also include any generated jobs.
  • storage – The storage that should be used for this particular session. The storage object holds references to existing directories in the file system. When restoring an existing dormant session it is important to use the correct storage object, the one that corresponds to the file system location used be the session before it was saved.
  • early_cb – A callback that allows the caller to “see” the session object early, before the bulk of resume operation happens. This method can be used to register callbacks on the new session before this method call returns. The callback accepts one argument, session, which is being resumed. This is being passed directly to plainbox.impl.session.resume.SessionResumeHelper.resume()
Ptype storage:

SessionStorage

Raises:

Anything that can be raised by load_checkpoint() and resume()

Returns:

Fresh instance of SessionManager

state[source]

SessionState associated with this manager

storage[source]

SessionStorage associated with this manager

class plainbox.impl.session.manager.WellKnownDirsHelper(storage)[source]

Helper class that knows about well known directories for SessionStorage.

This class simply gets rid of various magic directory names that we associate with session storage. It also provides a convenience utility method populate() to create all of those directories, if needed.

all_directories[source]

a list of all well-known directories

io_log_pathname[source]

full path of the directory where per-job IO logs are stored

populate()[source]

Create all of the well known directories that are expected to exist inside a freshly created session storage directory

storage[source]

SessionStorage associated with this helper

Previous topic

plainbox.impl.session.legacy – Legacy suspend/resume API

Next topic

plainbox.impl.session.resume – session resume handling

This Page