Skip to content

Commit 0d578d6

Browse files
[backport humble] fix threading shutdown (#1122)
Backport from #792 Co-authored-by: Christian Rauch <Rauch.Christian@gmx.de>
1 parent 76f4efb commit 0d578d6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

camera_calibration/src/camera_calibration/camera_calibrator.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(self, queue, function):
8686
self.function = function
8787

8888
def run(self):
89-
while True:
89+
while rclpy.ok():
9090
m = self.queue.get()
9191
self.function(m)
9292

@@ -262,18 +262,17 @@ def __init__(self, *args, **kwargs):
262262

263263
def spin(self):
264264
sth = SpinThread(self)
265-
sth.setDaemon(True)
266265
sth.start()
267266

268-
while True:
267+
while rclpy.ok():
269268
if self.queue_display.qsize() > 0:
270269
self.image = self.queue_display.get()
271270
cv2.imshow("display", self.image)
272271
else:
273272
time.sleep(0.1)
274273
k = cv2.waitKey(6) & 0xFF
275274
if k in [27, ord('q')]:
276-
rclpy.shutdown()
275+
return
277276
elif k == ord('s') and self.image is not None:
278277
self.screendump(self.image)
279278

camera_calibration/src/camera_calibration/nodes/cameracalibrator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def main():
224224
checkerboard_flags=checkerboard_flags, max_chessboard_speed=options.max_chessboard_speed,
225225
queue_size=options.queue_size)
226226
node.spin()
227+
rclpy.shutdown()
227228

228229
if __name__ == "__main__":
229230
try:

0 commit comments

Comments
 (0)