aboutsummaryrefslogtreecommitdiff
path: root/rumba/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'rumba/utils.py')
-rw-r--r--rumba/utils.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/rumba/utils.py b/rumba/utils.py
index 7417074..2a8c6b7 100644
--- a/rumba/utils.py
+++ b/rumba/utils.py
@@ -54,15 +54,20 @@ class ExperimentManager(object):
pass
def __exit__(self, exc_type, exc_val, exc_tb):
- if self.do_swap_out == self.PROMPT:
- logger.info('Press ENTER to start swap out.')
- input('')
- if self.do_swap_out == self.PROMPT \
- or self.do_swap_out == self.AUTO:
- 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))
- logger.debug('Exception details:', exc_info=exc_val)
- time.sleep(0.1) # Give the queue logger enough time to flush.
- return True # Suppress the exception we logged: no traceback.
+ try:
+ if self.do_swap_out == self.PROMPT:
+ logger.info('Press ENTER to start swap out.')
+ input('')
+ if self.do_swap_out == self.PROMPT \
+ or self.do_swap_out == self.AUTO:
+ 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))
+ logger.debug('Exception details:', exc_info=exc_val)
+ finally:
+ log.flush_and_kill_logging()
+ # Make sure to print all logs before execution terminates,
+ # Specifically the last two error logs above.
+ return True
+ # Suppress the exception we logged: no traceback, unless requested.