From 83363500771fa3d47ed424442cd43b955a320d76 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Thu, 22 Jan 2026 20:51:31 +0100 Subject: [PATCH] Ignore AttributeError when deleting temporary audio buffers --- src/sounddevice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sounddevice.py b/src/sounddevice.py index 04c0ca2..ce20d80 100644 --- a/src/sounddevice.py +++ b/src/sounddevice.py @@ -51,6 +51,7 @@ __version__ = '0.5.4' import atexit as _atexit +import contextlib as _contextlib import os as _os import platform as _platform import sys as _sys @@ -2649,8 +2650,10 @@ def callback_exit(self): def finished_callback(self): self.event.set() # Drop temporary audio buffers to free memory - del self.data - del self.out + with _contextlib.suppress(AttributeError): + del self.data + with _contextlib.suppress(AttributeError): + del self.out # Drop CFFI objects to avoid reference cycles self.stream._callback = None self.stream._finished_callback = None