diff options
author | Marco Capitani <m.capitani@nextworks.it> | 2017-11-13 12:18:55 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-11-13 15:48:27 +0000 |
commit | 510bb2116ea3e6c0d2559fe1b0c465f010d74bfb (patch) | |
tree | 4f1d56841da5e01398557b33e209b58317ab5227 /examples/example.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/example.py')
-rwxr-xr-x | examples/example.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/example.py b/examples/example.py index 11e8331..9f0ce03 100755 --- a/examples/example.py +++ b/examples/example.py @@ -3,6 +3,7 @@ # An example script using the rumba package from rumba.model import * +from rumba.utils import ExperimentManager # import testbed plugins import rumba.testbeds.emulab as emulab @@ -44,12 +45,10 @@ exp = rl.Experiment(tb, nodes = [a, b]) print(exp) -try: +with ExperimentManager(exp): exp.swap_in() exp.bootstrap_prototype() c1 = Client("rinaperf", options ="-t perf -s 1000 -c 10000") s1 = Server("rinaperf", arrival_rate=2, mean_duration=5, options = "-l", nodes = [a], clients = [c1]) sb = StoryBoard(exp, duration=3600, servers = [s1]) sb.start() -finally: - exp.swap_out() |