From 54bcc35ba7d90a89d919f413d137996604054a20 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 17 Aug 2011 22:31:33 +0000 Subject: [PATCH] important bug fix (connection exception was causing losing of already retrieved data) --- lib/core/threads.py | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/core/threads.py b/lib/core/threads.py index a00ad4a20..49cc34189 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -96,35 +96,35 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio warnMsg = "running in a single-thread mode. This could take a while." logger.warn(warnMsg) - if numThreads > 1: - if startThreadMsg: - infoMsg = "starting %d threads" % numThreads - logger.info(infoMsg) - else: - threadFunction() - return - - # Start the threads - for numThread in range(numThreads): - thread = threading.Thread(target=exceptionHandledFunction, name=str(numThread), args=[threadFunction]) - - # Reference: http://stackoverflow.com/questions/190010/daemon-threads-explanation - if PYVERSION >= "2.6": - thread.daemon = True - else: - thread.setDaemon(True) - - try: - thread.start() - except threadError, errMsg: - errMsg = "error occured while starting new thread ('%s')" % errMsg - logger.critical(errMsg) - break - - threads.append(thread) - - # And wait for them to all finish try: + if numThreads > 1: + if startThreadMsg: + infoMsg = "starting %d threads" % numThreads + logger.info(infoMsg) + else: + threadFunction() + return + + # Start the threads + for numThread in range(numThreads): + thread = threading.Thread(target=exceptionHandledFunction, name=str(numThread), args=[threadFunction]) + + # Reference: http://stackoverflow.com/questions/190010/daemon-threads-explanation + if PYVERSION >= "2.6": + thread.daemon = True + else: + thread.setDaemon(True) + + try: + thread.start() + except threadError, errMsg: + errMsg = "error occured while starting new thread ('%s')" % errMsg + logger.critical(errMsg) + break + + threads.append(thread) + + # And wait for them to all finish alive = True while alive: alive = False