small improvements re: #33

This commit is contained in:
2025-07-01 10:34:03 -04:00
parent 0fe081597e
commit 1991e5b31b
2 changed files with 55 additions and 12 deletions

View File

@ -14,6 +14,7 @@ from .constructors import (
from utils import radio_util
from typing import Optional
from fastapi import FastAPI, BackgroundTasks, Request, Response, HTTPException
from starlette.concurrency import run_in_threadpool
from fastapi.responses import RedirectResponse, JSONResponse
@ -57,7 +58,7 @@ class Radio(FastAPI):
async def on_start(self) -> None:
logging.info("radio: Initializing")
self.loop.run_in_executor(None, self.radio_util.load_playlist)
await run_in_threadpool(self.radio_util.load_playlist)
async def radio_skip(
self, data: ValidRadioNextRequest, request: Request
@ -316,7 +317,7 @@ class Radio(FastAPI):
if len(self.radio_util.active_playlist) > 1:
self.radio_util.active_playlist.append(next) # Push to end of playlist
else:
self.loop.run_in_executor(None, self.radio_util.load_playlist)
await run_in_threadpool(self.radio_util.load_playlist)
self.radio_util.now_playing = next
next["start"] = time_started