Skip to content

Commit 0d2d6ac

Browse files
authored
Fix Python visualizer mutex usage (#33)
1 parent 5dfe62e commit 0d2d6ac

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

python/cli/visualization/visualizer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def onVioOutput(self, cameraPose, image=None, width=None, height=None, colorForm
465465
output['height'] = height
466466
output['colorFormat'] = colorFormat
467467

468-
if self.outputQueueMutex:
468+
with self.outputQueueMutex:
469469
self.outputQueue.append(output)
470470

471471
# In live mode, future vio outputs are discarded
@@ -482,7 +482,7 @@ def onMappingOutput(self, mapperOutput):
482482
"mapperOutput" : mapperOutput
483483
}
484484

485-
if self.outputQueueMutex:
485+
with self.outputQueueMutex:
486486
self.outputQueue.append(output)
487487

488488
def run(self):
@@ -497,10 +497,11 @@ def run(self):
497497
while True:
498498
if self.shouldPause: break
499499

500-
if self.outputQueueMutex and len(self.outputQueue) > 0:
501-
output = self.outputQueue.pop(0)
502-
else:
503-
break
500+
with self.outputQueueMutex:
501+
if len(self.outputQueue) > 0:
502+
output = self.outputQueue.pop(0)
503+
else:
504+
break
504505

505506
if output["type"] == "vio":
506507
vioOutput = output

0 commit comments

Comments
 (0)