From 05b5ab78328806bcfa9bf69fc215c0c626ad1ba3 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Sun, 27 Sep 2020 09:11:44 +0200 Subject: [PATCH] fix ProcessLookupError --- .../providers/group_player/__init__.py | 5 +++-- music_assistant/stream_manager.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/music_assistant/providers/group_player/__init__.py b/music_assistant/providers/group_player/__init__.py index 2a922af8..9f43eef0 100644 --- a/music_assistant/providers/group_player/__init__.py +++ b/music_assistant/providers/group_player/__init__.py @@ -343,9 +343,10 @@ class GroupPlayer(Player): "[%s] child player aborted stream: %s", self.player_id, child_player_id ) self.connected_clients.pop(child_player_id, None) - sox_proc.terminate() await sox_proc.communicate() - await sox_proc.wait() + sox_proc.terminate() + if sox_proc and sox_proc.returncode is None: + await sox_proc.wait() else: self.connected_clients.pop(child_player_id, None) LOGGER.debug( diff --git a/music_assistant/stream_manager.py b/music_assistant/stream_manager.py index 2cfb66b6..4b28477d 100755 --- a/music_assistant/stream_manager.py +++ b/music_assistant/stream_manager.py @@ -146,10 +146,10 @@ class StreamManager: ) if fill_buffer_task and not fill_buffer_task.cancelled(): fill_buffer_task.cancel() - sox_proc.terminate() await sox_proc.communicate() - await sox_proc.wait() - # raise GeneratorExit from exc + sox_proc.terminate() + if sox_proc and sox_proc.returncode is None: + await sox_proc.wait() else: LOGGER.debug( "[async_get_sox_stream] [%s/%s] finished", @@ -203,9 +203,10 @@ class StreamManager: LOGGER.debug("[async_queue_stream_flac] [%s] aborted", player_id) if fill_buffer_task and not fill_buffer_task.cancelled(): fill_buffer_task.cancel() - sox_proc.terminate() await sox_proc.communicate() - await sox_proc.wait() + sox_proc.terminate() + if sox_proc and sox_proc.returncode is None: + await sox_proc.wait() else: LOGGER.debug( "[async_queue_stream_flac] [%s] finished", @@ -469,9 +470,10 @@ class StreamManager: str(exc), ) # read remaining bytes - process.terminate() await process.communicate() - await process.wait() + process.terminate() + if process and process.returncode is None: + await process.wait() # signal end of stream event self.mass.signal_event(EVENT_STREAM_ENDED, streamdetails) -- 2.34.1