i've got a problem with recording Audio over Pyaudio on a Raspberry Pi. The purpose of my code is to record small audio snippets, 10s long, every 10s to 20s.
To do this, I'm starting an own Thread for the recorder:
# Create collect beat thread.
recorder_thread = Thread(target=beat_analyzer, args=(recorder_queue,))
recorder_thread.start()
It uses another class to control the timing (recorder_queue). The recording itself happens in beat_analyzer. Somehow this is working fine for some time... but after about one hour or two, I get the following exception:
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 505, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/pi/beatmap/bm-client/lib_recorder.py", line 134, in beat_analyzer
py_audio.terminate()
File "/usr/lib/pymodules/python2.7/pyaudio.py", line 644, in terminate
for stream in self._streams:
RuntimeError: Set changed size during iteration
As I'm not iterating over something (at least I don't know about it) I wonder where the problem comes from. If it's perhaps something inside Pyaudio that I need to workaround? Hints much appreciated.