From 4d1ef02802cc9742ed93acc367977113ed1aeda2 Mon Sep 17 00:00:00 2001 From: Eric Severance Date: Tue, 11 Aug 2020 14:20:43 -0700 Subject: [PATCH] Stream clients operate on a copy of the intnernal self._outputs dict (#38766) --- homeassistant/components/stream/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/stream/__init__.py b/homeassistant/components/stream/__init__.py index aeab212b78c..520e3047439 100644 --- a/homeassistant/components/stream/__init__.py +++ b/homeassistant/components/stream/__init__.py @@ -2,6 +2,7 @@ import logging import secrets import threading +from types import MappingProxyType import voluptuous as vol @@ -137,8 +138,10 @@ class Stream: @property def outputs(self): - """Return stream outputs.""" - return self._outputs + """Return a copy of the stream outputs.""" + # A copy is returned so the caller can iterate through the outputs + # without concern about self._outputs being modified from another thread. + return MappingProxyType(self._outputs.copy()) def add_provider(self, fmt): """Add provider output stream."""