diff --git a/fsl/utils/status.py b/fsl/utils/status.py index ba658e592a8de8f8bab6a9dd199ff86c18a73fe5..54b6ce6e4710eca9f8d6ac9327985a50422cf27a 100644 --- a/fsl/utils/status.py +++ b/fsl/utils/status.py @@ -150,14 +150,25 @@ class ClearThread(threading.Thread): (via a call to :func:`clearStatus`). """ - while True: + # http://bugs.python.org/issue14623 + # + # When the main thread exits, daemon threads will + # continue to run after the threading module is + # destroyed. Calls to the Event methods can thus + # result in errors. + try: - self.__vetoEvent .clear() - self.__clearEvent.wait() - self.__clearEvent.clear() + while True: - if not self.__clearEvent.wait(self.__timeout) and \ - not self.__vetoEvent.isSet(): - - log.debug('Timeout - clearing status') - clearStatus() + self.__vetoEvent .clear() + self.__clearEvent.wait() + self.__clearEvent.clear() + + if not self.__clearEvent.wait(self.__timeout) and \ + not self.__vetoEvent.isSet(): + + log.debug('Timeout - clearing status') + clearStatus() + + except: + pass