Skip to content

Commit

Permalink
attempt to fix #101
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwlouse committed Mar 13, 2016
1 parent 79ee926 commit bc9c0f3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions sacred/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(self, config, config_modifications, main_function, observers,

self._heartbeat = None
self._failed_observers = []
self._output_capturer = None

def open_resource(self, filename):
"""Open a file and also save it as a resource.
Expand Down Expand Up @@ -139,7 +140,7 @@ def __call__(self, *args):

self.warn_if_unobserved()
set_global_seed(self.config['seed'])
with tee_output() as self.captured_out:
with tee_output() as self._output_capturer:
self.run_logger.info('Started')

self._emit_started()
Expand All @@ -162,9 +163,8 @@ def __call__(self, *args):
raise
finally:
self._warn_about_failed_observers()
self.captured_out.flush()
self.captured_out = self.captured_out.getvalue()
self.final = True
self._output_capturer.flush()
self.captured_out = self._output_capturer.getvalue()

def _start_heartbeat(self):
self._emit_heatbeat()
Expand Down Expand Up @@ -195,10 +195,11 @@ def _emit_started(self):

def _emit_heatbeat(self):
beat_time = datetime.datetime.now()
self.captured_out = self._output_capturer.getvalue()
for observer in self.observers:
self._safe_call(observer, 'heartbeat_event',
info=self.info,
captured_out=self.captured_out.getvalue(),
captured_out=self.captured_out,
beat_time=beat_time)

def _stop_time(self):
Expand Down

0 comments on commit bc9c0f3

Please sign in to comment.