diff options
author | Marco Capitani <[email protected]> | 2017-11-13 12:18:55 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-11-13 15:48:27 +0000 |
commit | 510bb2116ea3e6c0d2559fe1b0c465f010d74bfb (patch) | |
tree | 4f1d56841da5e01398557b33e209b58317ab5227 /examples/two-layers.py | |
parent | 9d15d1117c80ee9313d0dc391488efb9bb060a4a (diff) | |
download | rumba-510bb2116ea3e6c0d2559fe1b0c465f010d74bfb.tar.gz rumba-510bb2116ea3e6c0d2559fe1b0c465f010d74bfb.zip |
utils, examples: Add ExperimentManager CM
Adds an ExperimentManager context manager for scripts:
- No more ugly stack traces after execution if something goes wrong
- No more ugly and easy to forget try-finally blocks
Diffstat (limited to 'examples/two-layers.py')
-rwxr-xr-x | examples/two-layers.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/two-layers.py b/examples/two-layers.py index 6d22673..6e4671f 100755 --- a/examples/two-layers.py +++ b/examples/two-layers.py @@ -16,7 +16,7 @@ import rumba.prototypes.rlite as rl import rumba.prototypes.irati as irati import rumba.log as log - +from rumba.utils import ExperimentManager log.set_logging_level('DEBUG') @@ -54,8 +54,10 @@ exp = rl.Experiment(tb, nodes = [a, b, c, d]) print(exp) -try: +with ExperimentManager(exp): exp.swap_in() exp.bootstrap_prototype() -finally: - exp.swap_out() + sb = StoryBoard(exp, duration=15, servers=[]) + sb.run_command(7.5, a, 'echo "7.5 secs in. We are at $(hostname)"') + sb.run_command(12, b, 'echo "12 secs in. We are at $(hostname)"') + sb.start() |