soundd: use with statement for wave.open to ensure proper resource cleanup (#34815)

use with statement for wave.open to ensure proper resource cleanup
pull/34720/merge
Dean Lee 2 months ago committed by GitHub
parent 3e629acf79
commit fa79b29cba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      selfdrive/ui/soundd.py

@ -69,8 +69,7 @@ class Soundd:
for sound in sound_list: for sound in sound_list:
filename, play_count, volume = sound_list[sound] filename, play_count, volume = sound_list[sound]
wavefile = wave.open(BASEDIR + "/selfdrive/assets/sounds/" + filename, 'r') with wave.open(BASEDIR + "/selfdrive/assets/sounds/" + filename, 'r') as wavefile:
assert wavefile.getnchannels() == 1 assert wavefile.getnchannels() == 1
assert wavefile.getsampwidth() == 2 assert wavefile.getsampwidth() == 2
assert wavefile.getframerate() == SAMPLE_RATE assert wavefile.getframerate() == SAMPLE_RATE

Loading…
Cancel
Save