Session

import kloch.session
class kloch.session.SessionDirectory(path: Path)

Manage the filesystem directory to store data during a kloch launcher session.

Most of the data stored is arbitrary and generated depending on the launcher.

property identifier: str
classmethod initialize(root: Path) SessionDirectory

Generate a new unique session directory on the filesystem.

This function should be safe to be executed from different thread on the same machine at the same time.

meta_session_path

A file indicating the directory is a session and which contains the timestamp at which the session was created.

path: Path

Filesystem path to an existing directory.

profile_path

A file which contain the merged profile used to start the session.

property timestamp: float
kloch.session.clean_outdated_session_dirs(root: Path, lifetime: float) List[Path]

Iterate through all existing session directories and delete the one which have been created longer than the given lifetime.

This function should handle file or dirs of the given root which are not sessions.

Parameters:
  • root – filesystem path to an existing directory.

  • lifetime – maximum lifetime in hours of a session directory

Returns:

list of directories filesystem path that have been removed

kloch.session.get_session_dirs(root: Path) List[SessionDirectory]

Get all the session directories found in the given root directory.