Do not let daemon threads be stopped while being updated
This commit is contained in:
parent
674a211cda
commit
b0495d028f
|
@ -44,6 +44,7 @@ class ThreadedSegment(Thread):
|
|||
|
||||
def shutdown(self):
|
||||
self.keep_going = False
|
||||
self.update_lock.acquire()
|
||||
|
||||
def set_interval(self, interval=None, **kwargs):
|
||||
# Allowing “interval” keyword in configuration.
|
||||
|
|
|
@ -40,6 +40,9 @@ class Renderer(object):
|
|||
def get_theme(self, matcher_info):
|
||||
return self.theme
|
||||
|
||||
def shutdown(self):
|
||||
self.theme.shutdown()
|
||||
|
||||
def get_highlighting(self, segment, mode):
|
||||
segment['highlight'] = self.colorscheme.get_highlighting(segment['highlight_group'], mode, segment.get('gradient_level'))
|
||||
if segment['divider_highlight_group']:
|
||||
|
|
|
@ -14,10 +14,10 @@ def mergeargs(argvalue):
|
|||
|
||||
|
||||
class ShellPowerline(Powerline):
|
||||
def __init__(self, args):
|
||||
def __init__(self, args, run_once=False):
|
||||
self.args = args
|
||||
self.theme_option = mergeargs(args.theme_option) or {}
|
||||
super(ShellPowerline, self).__init__(args.ext[0], args.renderer_module, run_once=True)
|
||||
super(ShellPowerline, self).__init__(args.ext[0], args.renderer_module, run_once=run_once)
|
||||
|
||||
def get_segment_info(self):
|
||||
return self.args
|
||||
|
|
|
@ -12,7 +12,7 @@ except ImportError:
|
|||
|
||||
if __name__ == '__main__':
|
||||
args = get_argparser(description=__doc__).parse_args()
|
||||
powerline = ShellPowerline(args)
|
||||
powerline = ShellPowerline(args, run_once=True)
|
||||
rendered = powerline.renderer.render(width=args.width, side=args.side)
|
||||
try:
|
||||
sys.stdout.write(rendered)
|
||||
|
|
|
@ -49,6 +49,7 @@ class TestConfig(TestCase):
|
|||
check_output(1, 0)
|
||||
finally:
|
||||
vim_module._start_mode('n')
|
||||
powerline.renderer.shutdown()
|
||||
|
||||
def test_tmux(self):
|
||||
from powerline.segments import common
|
||||
|
@ -56,16 +57,16 @@ class TestConfig(TestCase):
|
|||
reload(common)
|
||||
from powerline.shell import ShellPowerline
|
||||
with replace_module_attr(common, 'urllib_read', urllib_read):
|
||||
ShellPowerline(Args(ext=['tmux'])).renderer.render()
|
||||
ShellPowerline(Args(ext=['tmux']), run_once=True).renderer.render()
|
||||
reload(common)
|
||||
|
||||
def test_zsh(self):
|
||||
from powerline.shell import ShellPowerline
|
||||
ShellPowerline(Args(last_pipe_status=[1, 0], ext=['shell'], renderer_module='zsh_prompt')).renderer.render()
|
||||
ShellPowerline(Args(last_pipe_status=[1, 0], ext=['shell'], renderer_module='zsh_prompt'), run_once=True).renderer.render()
|
||||
|
||||
def test_bash(self):
|
||||
from powerline.shell import ShellPowerline
|
||||
ShellPowerline(Args(last_exit_code=1, ext=['shell'], renderer_module='bash_prompt', config=[('ext', {'shell': {'theme': 'default_leftonly'}})])).renderer.render()
|
||||
ShellPowerline(Args(last_exit_code=1, ext=['shell'], renderer_module='bash_prompt', config=[('ext', {'shell': {'theme': 'default_leftonly'}})]), run_once=True).renderer.render()
|
||||
|
||||
def test_ipython(self):
|
||||
from powerline.ipython import IpythonPowerline
|
||||
|
@ -75,7 +76,9 @@ class TestConfig(TestCase):
|
|||
config_overrides = None
|
||||
theme_overrides = {}
|
||||
|
||||
IpyPowerline().renderer.render()
|
||||
powerline = IpyPowerline()
|
||||
powerline.renderer.render()
|
||||
powerline.renderer.shutdown()
|
||||
|
||||
def test_wm(self):
|
||||
from powerline.segments import common
|
||||
|
@ -83,7 +86,7 @@ class TestConfig(TestCase):
|
|||
reload(common)
|
||||
from powerline import Powerline
|
||||
with replace_module_attr(common, 'urllib_read', urllib_read):
|
||||
Powerline(ext='wm', renderer_module='pango_markup').renderer.render()
|
||||
Powerline(ext='wm', renderer_module='pango_markup', run_once=True).renderer.render()
|
||||
reload(common)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue