From 4ca37901dab437d0cc3bce48f39772b47a1d2a1d Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 22 Jun 2011 14:53:42 +0000 Subject: [PATCH] thread safe logging+stdout (no more overlapping of log messages and raw output) --- lib/core/common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/core/common.py b/lib/core/common.py index e3c31ecf0..ce61fb9af 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -663,6 +663,7 @@ def dataToStdout(data, forceOutput=False): if not ('threadException' in kb and kb.threadException): if forceOutput or not getCurrentThreadData().disableStdOut: try: + logging._acquireLock() # Reference: http://bugs.python.org/issue1602 if IS_WIN: output = data.encode('ascii', "replace") @@ -684,6 +685,7 @@ def dataToStdout(data, forceOutput=False): sys.stdout.write(data.encode(UNICODE_ENCODING)) finally: sys.stdout.flush() + logging._releaseLock() def dataToSessionFile(data): if not conf.sessionFile or kb.suppressSession: @@ -772,7 +774,9 @@ def readInput(message, default=None): data = default else: + logging._acquireLock() data = raw_input(message.encode(sys.stdout.encoding or UNICODE_ENCODING)) + logging._releaseLock() if not data: data = default