Use 'with' instead of lock.acquire/release()

This commit is contained in:
S0lll0s 2014-02-07 13:14:56 +01:00
parent 253ad02c3c
commit 21319fc8d2
1 changed files with 5 additions and 6 deletions

View File

@ -25,12 +25,11 @@ lock = Lock()
def render( event=None, data=None, sub=None ):
global lock
lock.acquire()
s = '[\n' + powerline.render(side='right')[:-2] + '\n]\n'
s += ',[\n' + powerline.render(side='left' )[:-2] + '\n]'
print ',[\n' + s + '\n]'
sys.stdout.flush()
lock.release()
with lock:
s = '[\n' + powerline.render(side='right')[:-2] + '\n]\n'
s += ',[\n' + powerline.render(side='left' )[:-2] + '\n]'
print ',[\n' + s + '\n]'
sys.stdout.flush()
sub = i3.Subscription( render, 'workspace' )