Add set_event argument to .shutdown() method

This commit is contained in:
ZyX 2013-04-09 00:19:06 +04:00 committed by ZyX
parent bbe3210bb6
commit 85189e8b36
1 changed files with 17 additions and 8 deletions
powerline

View File

@ -726,15 +726,24 @@ class Powerline(object):
pass pass
yield FailedUnicode(safe_unicode(e)) yield FailedUnicode(safe_unicode(e))
def shutdown(self): def shutdown(self, set_event=True):
'''Shut down all background threads. Must be run only prior to exiting '''Shut down all background threads.
current application.
:param bool set_event:
Set ``shutdown_event`` and call ``renderer.shutdown`` which should
shut down all threads. Set it to False unless you are exiting an
application.
If set to False this does nothing more then resolving reference
cycle ``powerline config_loader bound methods powerline`` by
unsubscribing from config_loader events.
''' '''
self.shutdown_event.set() if set_event:
try: self.shutdown_event.set()
self.renderer.shutdown() try:
except AttributeError: self.renderer.shutdown()
pass except AttributeError:
pass
functions = tuple(self.cr_callbacks.values()) functions = tuple(self.cr_callbacks.values())
self.config_loader.unregister_functions(set(functions)) self.config_loader.unregister_functions(set(functions))
self.config_loader.unregister_missing(set(((self.find_config_files, function) for function in functions))) self.config_loader.unregister_missing(set(((self.find_config_files, function) for function in functions)))