You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-27 06:03:52 +01:00
prevent zombie processes
This commit is contained in:
@@ -28,7 +28,13 @@ class ProcessManager(ABC_ProcessManager):
|
|||||||
return pr
|
return pr
|
||||||
def anything_playing(self) -> bool:
|
def anything_playing(self) -> bool:
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.processes = [p for p in self.processes if p.process.poll() is None]
|
alive = []
|
||||||
|
for p in self.processes:
|
||||||
|
if p.process.poll() is None: alive.append(p)
|
||||||
|
else:
|
||||||
|
try: p.process.wait(timeout=0)
|
||||||
|
except subprocess.TimeoutExpired: pass
|
||||||
|
self.processes = alive
|
||||||
return bool(self.processes)
|
return bool(self.processes)
|
||||||
def stop_all(self, timeout: float | None = None) -> None:
|
def stop_all(self, timeout: float | None = None) -> None:
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
|||||||
@@ -267,12 +267,14 @@ class RadioPlayer:
|
|||||||
pr = self.procman.play(track)
|
pr = self.procman.play(track)
|
||||||
[module.on_new_track(song_i, pr.track, next_track) for module in self.modman.simple_modules if module]
|
[module.on_new_track(song_i, pr.track, next_track) for module in self.modman.simple_modules if module]
|
||||||
end_time = pr.started_at + pr.duration + pr.track.focus_time_offset
|
end_time = pr.started_at + pr.duration + pr.track.focus_time_offset
|
||||||
|
self.procman.anything_playing()
|
||||||
|
|
||||||
while end_time >= time.monotonic() and pr.process.poll() is None:
|
while end_time >= time.monotonic() and pr.process.poll() is None:
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
[module.progress(song_i, track, time.monotonic() - pr.started_at, pr.duration, end_time - pr.started_at) for module in self.modman.simple_modules if module]
|
[module.progress(song_i, track, time.monotonic() - pr.started_at, pr.duration, end_time - pr.started_at) for module in self.modman.simple_modules if module]
|
||||||
if (elapsed := time.monotonic() - start) < 1 and (remaining_until_end := end_time - time.monotonic()) > 0: time.sleep(min(1 - elapsed, remaining_until_end))
|
if (elapsed := time.monotonic() - start) < 1 and (remaining_until_end := end_time - time.monotonic()) > 0: time.sleep(min(1 - elapsed, remaining_until_end))
|
||||||
|
|
||||||
|
self.procman.anything_playing()
|
||||||
if next_track: prefetch(next_track.path)
|
if next_track: prefetch(next_track.path)
|
||||||
i += 1
|
i += 1
|
||||||
if not extend: song_i += 1
|
if not extend: song_i += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user