fix ProcessLookupError
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 27 Sep 2020 07:11:44 +0000 (09:11 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sun, 27 Sep 2020 07:11:44 +0000 (09:11 +0200)
music_assistant/providers/group_player/__init__.py
music_assistant/stream_manager.py

index 2a922af8ac8a1a4bbe4de0a78aa2773d0f8cf451..9f43eef0152487008ce244f6f5321bda019e3e8e 100644 (file)
@@ -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(
index 2cfb66b645f6961e3c06c61110d94328f7cde723..4b28477d6e5d5bf3165e056d36befe310cb082f4 100755 (executable)
@@ -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)