Add timeout to thread join calls to avoid deadlocks

This commit is contained in:
Kim Silkebækken 2013-04-05 15:42:56 +02:00
parent dc1e646308
commit 17065b4c7e
2 changed files with 4 additions and 2 deletions

View File

@ -412,7 +412,8 @@ class Powerline(object):
'''
self.shutdown_event.set()
if self.use_daemon_threads and self.is_alive():
self.thread.join()
# Give the worker thread a chance to shutdown, but don't block for too long
self.thread.join(.01)
self.renderer.shutdown()
self.watcher.unsubscribe()

View File

@ -77,7 +77,8 @@ class ThreadedSegment(object):
def shutdown(self):
self.shutdown_event.set()
if self.daemon and self.is_alive():
self.thread.join()
# Give the worker thread a chance to shutdown, but don't block for too long
self.thread.join(.01)
def set_interval(self, interval=None):
# Allowing “interval” keyword in configuration.