aşağıdaki fonksiyonlarda start_commination aktif olduğunda zamanla bellek kuullanımında artış söz konusu oluyor. 150mb lerden 600mb ram tüketimine kadar gidiyor. ancak sebebini anlayamadım. başka fonksiyonlarda da içinde while olan kısımlar var ama böyle bir durum söz konusu değildi.
def send_audio_e(self):
p = pyaudio.PyAudio()
stream = p.open(
format=pyaudio.paInt16,
channels=self.CHANNELS,
rate=44100,
input=True,
frames_per_buffer=self.CHUNK,
)
try:
while True:
if self.is_running:
data = stream.read(self.CHUNK)
audio_data = np.frombuffer(data, dtype=np.int16)
audio_data = audio_data.tobytes()
#print(audio_data)
try:
sio.emit(
"audio_data", {"audio_data": audio_data}
) # Bytlara dönüştürülen ses verilerini 'audio_data' sözcüğü ile emitle
except Exception as e:
print(e)
except Exception as e:
print("hata",e)
finally:
print("kapandı")
stream.stop_stream()
stream.close()
p.terminate()
def start_communication(self):
threading.Thread(target=self.send_audio_e).start()