blob: 5348b0a5841565207c8643092e57c3334a8b617f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import time
import rumba.log as log
import rumba.model as model
logger = log.get_logger(__name__)
class ExperimentManager(object):
def __init__(self, experiment, do_swap_out=True):
assert isinstance(experiment, model.Experiment), \
'An experiment instance is required.'
self.experiment = experiment
self.do_swap_out = do_swap_out
def __enter__(self):
pass
def __exit__(self, exc_type, exc_val, exc_tb):
if self.do_swap_out:
self.experiment.swap_out()
if exc_val is not None:
logger.error('Something went wrong. Got %s: %s',
type(exc_val).__name__, str(exc_val))
time.sleep(0.1) # Give the queue logger enough time to flush.
return True # Suppress the exception we logged: no traceback.
|