From 002288d632813d567db8d3a26dd76d991687cb9c Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 27 Feb 2022 17:14:31 -0500 Subject: [PATCH] Error catching for cleaning up --- sound.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sound.py b/sound.py index be7cf28..e0f0eb1 100644 --- a/sound.py +++ b/sound.py @@ -30,8 +30,15 @@ class PCMStream: def clean_up(self): if self.stream is not None: - self.stream.stop() - self.stream.close() + try: + self.stream.stop() + except Exception as e: + print(f"Error on Stop: '{e}'") + + try: + self.stream.close() + except Exception as e: + print(f"Error on Close: '{e}'") class DeviceNotFoundError(Exception):