Subprocess.Popen 几秒钟后停止(或出现故障)

Subprocess.Popen stops ( or malfunctions) after a few seconds

我是一个完全的初学者,对于任何错误,我深表歉意。这是我在 Python 3.5 中的代码。它在 Raspberry Pi 上的 Raspbian 中执行 3.

import subprocess

radio = subprocess.Popen(["mplayer", 'http://edge-bauerabsolute-02-gos1.sharp-stream.com/absolute90s.mp3?'], shell = False , stdout=subprocess.PIPE)

print ("Other code - no waiting for the subprocess to finish")

收音机播放了大约 30 秒,然后停止。我希望它在后台 运行 没有脚本等待子进程结束。此外,在 Linux 中,如果我停止脚本,收音机将作为 mplayer 的 运行ning 进程再次返回(所以 python 脚本一定是以某种方式停止了它?)

似乎子进程继续但 music/sound 停止了。它似乎与互联网连接无关,如果我等待它也不会再次启动。我试过 radio.communicate() 或 radio.stdout.read() ,这很有趣,可以让我的收音机连续播放,但不会继续执行脚本。我也没有任何输出,脚本只是保留。

问题:如何允许 'radio' 进程在后台继续(同时播放音乐)同时脚本执行其他操作?

幸运的是我自己解决了。 subprocess.PIPE 显然 stops/interferes 与过程有关,所以我没有像这样执行 DEVNULL 而不是 stdout=subprocess.PIPE:

DEVNULL = open(os.devnull, 'wb')
radiostream = subprocess.Popen(["mplayer", 'http://edge-bauerabsolute-02-gos1.sharp-stream.com/absolute90s.mp3?&'], shell = False, stdout=DEVNULL, stderr=DEVNULL)