From f78a355042931f214a98b2f1c015d17afe15b000 Mon Sep 17 00:00:00 2001 From: fijal Date: Mon, 6 Aug 2007 15:57:55 +0200 Subject: [PATCH] [svn r45518] Print out communicate atomically --HG-- branch : trunk --- py/test/rsession/reporter.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/py/test/rsession/reporter.py b/py/test/rsession/reporter.py index 176b2b3ee..cedf9c464 100644 --- a/py/test/rsession/reporter.py +++ b/py/test/rsession/reporter.py @@ -14,6 +14,7 @@ from py.__.misc.terminal_helper import ansi_print, get_terminal_width from py.__.test.representation import Presenter import sys +import thread class AbstractReporter(object): def __init__(self, config, hosts): @@ -27,23 +28,28 @@ class AbstractReporter(object): self.skipped = dict([(host, 0) for host in hosts]) self.passed = dict([(host, 0) for host in hosts]) self.to_rsync = {} + self.lock = thread.allocate_lock() def get_item_name(self, event, colitem): return "/".join(colitem.listnames()) def report(self, what): - repfun = getattr(self, "report_" + what.__class__.__name__, - self.report_unknown) try: - return repfun(what) - except (KeyboardInterrupt, SystemExit): - raise - except: - print "Internal reporting problem" - excinfo = py.code.ExceptionInfo() - for i in excinfo.traceback: - print str(i)[2:-1] - print excinfo + self.lock.acquire() + repfun = getattr(self, "report_" + what.__class__.__name__, + self.report_unknown) + try: + return repfun(what) + except (KeyboardInterrupt, SystemExit): + raise + except: + print "Internal reporting problem" + excinfo = py.code.ExceptionInfo() + for i in excinfo.traceback: + print str(i)[2:-1] + print excinfo + finally: + self.lock.release() def report_unknown(self, what): if self.config.option.verbose: