Skip to content

Commit 93ad9cc

Browse files
committed
Add try-except to filter RuntimeError exceptions
1 parent 596f47e commit 93ad9cc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

plugwise_usb/connection/receiver.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,13 @@ async def _data_queue_worker(self) -> None:
225225
"""Convert collected data into messages and place then im message queue."""
226226
_LOGGER.debug("Data queue worker started")
227227
while self.is_connected:
228-
if (data := await self._data_queue.get()) != b"FFFFFFFF":
228+
try:
229+
data = await self._data_queue.get()
230+
except RuntimeError:
231+
_LOGGER.debug("No response to add to data_worker_queue")
232+
return
233+
234+
if data != b"FFFFFFFF":
229235
if (response := self.extract_message_from_data(data)) is not None:
230236
await self._put_message_in_queue(response)
231237
self._data_queue.task_done()
@@ -279,7 +285,12 @@ async def _message_queue_worker(self) -> None:
279285
"""Process messages in receiver queue."""
280286
_LOGGER.debug("Message queue worker started")
281287
while self.is_connected:
282-
response: PlugwiseResponse = await self._message_queue.get()
288+
try:
289+
response: PlugwiseResponse = await self._message_queue.get()
290+
except RuntimeError:
291+
_LOGGER.debug("No response to add to message_worker_queue")
292+
return
293+
283294
if response.priority == Priority.CANCEL:
284295
self._message_queue.task_done()
285296
return

0 commit comments

Comments
 (0)