pcvs.backend.session module
- class pcvs.backend.session.Session(date=None, path='.')[source]
Bases:
object
Object representing a running validation (detached or not).
Despite the fact it is designed for manage concurrent runs, it takes a callback and can be derived for other needs.
- Parameters:
- class State(value)[source]
Bases:
IntEnum
Enum of possible Session states.
- COMPLETED = 2
- ERROR = 3
- IN_PROGRESS = 1
- WAITING = 0
- classmethod from_yaml(constructor, node)[source]
Construct a
Session.State
from its YAML representation.Relies on the fact the node contains a ‘Session.State’ tag. :param loader: the YAML loader :type loader:
yaml.FullLoader
:type node: :param node: the YAML representation :type node: Any :return: The session State as an object :rtype:Session.State
- classmethod to_yaml(representer, data)[source]
Convert a Test.State to a valid YAML representation.
A new tag is created: ‘Session.State’ as a scalar (str). :param dumper: the YAML dumper object :type dumper:
YAML().dumper
:type data: :param data: the object to represent :type data: class:Session.State :return: the YAML representation :rtype: Any
- property(kw)[source]
Access specific data from the session stored info session.yml.
- Parameters:
kw (str) – the information to retrieve. kw must be a valid key
- Returns:
the requested session infos if exist
- Return type:
Any
- register_callback(callback)[source]
Register the callback used as main function once the session is started.
- Parameters:
callback (Callable) – function to invoke
- run(*args, **kwargs)[source]
Run the session normally, without detaching the focus.
Arguments are user function ones. This function is also in charge of redirecting I/O properly (stdout, file, logs)
- Parameters:
args (tuple) – user function positional arguments
:param kwargs user function keyword-based arguments. :type kwargs: tuple
- run_detached(*args, **kwargs)[source]
Run the session is detached mode.
Arguments are for user function only. :type args: :param args: user function positional arguments :type args: tuple :param kwargs user function keyword-based arguments. :type kwargs: tuple
- Returns:
the Session id created for this run.
- Return type:
- pcvs.backend.session.list_alive_sessions()[source]
Load and return the complete dict from session.yml file
- Returns:
the session dict
- Return type:
- pcvs.backend.session.lock_session_file(timeout=None)[source]
Acquire the lockfil before manipulating the session.yml file.
This ensure safety between multiple PCVS instances. Be sure to call unlock_session_file() once completed
- Parameters:
timeout (int) – return from blocking once timeout is expired (raising TimeoutError)
- pcvs.backend.session.main_detached_session(sid, user_func, *args, **kwargs)[source]
Main function processed when running in detached mode.
This function is called by Session.run_detached() and is launched from cloned process (same global env, new main function).
- pcvs.backend.session.remove_session_from_file(sid)[source]
clear a session from logs.
- Parameters:
sid (int) – the session id to remove.
- pcvs.backend.session.store_session_to_file(c)[source]
Save a new session into the session file (in HOME dir).
- pcvs.backend.session.unlock_session_file()[source]
Release the lock after manipulating the session.yml file.
The call won’t fail if the lockfile is not taken before unlocking.