Author: bugman Date: Thu Jan 7 11:43:51 2010 New Revision: 10123 URL: http://svn.gna.org/viewcvs/relax?rev=10123&view=rev Log: Bug fix for the STDOUT and STDERR handling by the multi module. The IO streams are no longer lost in the case of an error. This allows the relax test suite to function correctly in uni-processor mode. The multi-processor mode might require more work. Modified: branches/multi_processor_merge/multi/processor.py branches/multi_processor_merge/multi/uni_processor.py Modified: branches/multi_processor_merge/multi/processor.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/processor.py?rev=10123&r1=10122&r2=10123&view=diff ============================================================================== --- branches/multi_processor_merge/multi/processor.py (original) +++ branches/multi_processor_merge/multi/processor.py Thu Jan 7 11:43:51 2010 @@ -487,6 +487,10 @@ self._processor_size = processor_size '''Number of slave processors available in this processor.''' + # Default STDOUT and STDERR for restoring later on. + self.orig_stdout = sys.__stdout__ + self.orig_stderr = sys.__stderr__ + # CHECKME: integration with with stdo capture on slaves # setup captured std output and error streams used for capturing and modifying proccessor # output on masters and slaves @@ -554,9 +558,13 @@ if stdio_capture == None: stdio_capture = self.stdio_capture - # IO redirection. - sys.stdout = self.stdio_capture[0] - sys.stderr = self.stdio_capture[1] + # First flush. + sys.stdout.flush() + sys.stderr.flush() + + # Then redirect IO. + sys.stdout = stdio_capture[0] + sys.stderr = stdio_capture[1] # FIXME is this used? @@ -850,7 +858,7 @@ if self.rank() == 0: stdout_capture = PrependOut(pre_strings[0], sys.stdout) #FIXME: seems to be that writing to stderr results leads to incorrect serialisation of output - stderr_capture = PrependOut(pre_strings[1], sys.__stdout__) + stderr_capture = PrependOut(pre_strings[1], sys.stderr) else: stdout_capture = PrependStringIO(pre_strings[0]) stderr_capture = PrependStringIO(pre_strings[1], target_stream=stdout_capture) Modified: branches/multi_processor_merge/multi/uni_processor.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/uni_processor.py?rev=10123&r1=10122&r2=10123&view=diff ============================================================================== --- branches/multi_processor_merge/multi/uni_processor.py (original) +++ branches/multi_processor_merge/multi/uni_processor.py Thu Jan 7 11:43:51 2010 @@ -51,8 +51,6 @@ self.command_queue = [] self.memo_map = {} - - self.slave_stdio_capture = self.std_stdio_capture(pre_strings=('', '')) def add_to_queue(self, command, memo=None): @@ -137,7 +135,7 @@ for i, command in enumerate(self.command_queue): completed = (i == last_command) - self.capture_stdio(self.slave_stdio_capture) + self.capture_stdio(self.std_stdio_capture(pre_strings=('', ''))) command.run(self, completed) self.restore_stdio()