Pass run_once to ConfigLoader, make it respect run_once
It only respects run_once by using DummyWatcher instead of a watcher doing something potentially useful Ref #711
This commit is contained in:
parent
db80fc95ed
commit
6a4b8bc49c
|
@ -121,7 +121,7 @@ class Powerline(object):
|
|||
'load_theme': True,
|
||||
}
|
||||
self.shutdown_event = shutdown_event or Event()
|
||||
self.config_loader = config_loader or ConfigLoader(shutdown_event=self.shutdown_event)
|
||||
self.config_loader = config_loader or ConfigLoader(shutdown_event=self.shutdown_event, run_once=run_once)
|
||||
self.run_loader_update = False
|
||||
|
||||
self.renderer_options = {}
|
||||
|
|
|
@ -20,11 +20,22 @@ def load_json_config(config_file_path, load=json.load, open_file=open_file):
|
|||
return load(config_file_fp)
|
||||
|
||||
|
||||
class DummyWatcher(object):
|
||||
def __call__(self, *args, **kwargs):
|
||||
return False
|
||||
|
||||
def watch(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class ConfigLoader(MultiRunnedThread):
|
||||
def __init__(self, shutdown_event=None, watcher=None, load=load_json_config):
|
||||
def __init__(self, shutdown_event=None, watcher=None, load=load_json_config, run_once=False):
|
||||
super(ConfigLoader, self).__init__()
|
||||
self.shutdown_event = shutdown_event or Event()
|
||||
self.watcher = watcher or create_file_watcher()
|
||||
if run_once:
|
||||
self.watcher = DummyWatcher()
|
||||
else:
|
||||
self.watcher = watcher or create_file_watcher()
|
||||
self._load = load
|
||||
|
||||
self.pl = None
|
||||
|
|
Loading…
Reference in New Issue