From 25d92f500d8fcdb40478334ecb950e238478aeb6 Mon Sep 17 00:00:00 2001 From: Jordan Shatford Date: Wed, 1 Nov 2023 09:33:41 +1100 Subject: [PATCH] fix(api): return status stream directly for status endpoint Signed-off-by: Jordan Shatford --- apps/api/app/routers/downloads.py | 5 ++--- core/ydcore/manager.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/api/app/routers/downloads.py b/apps/api/app/routers/downloads.py index 89774097..203a8a0e 100644 --- a/apps/api/app/routers/downloads.py +++ b/apps/api/app/routers/downloads.py @@ -75,14 +75,13 @@ async def status_stream(request: Request, session: Session): # Exclude from OpenAPI schema as there is no support for Server Sent Events. @router.get('/status', include_in_schema=False) -async def get_downloads_status( +def get_downloads_status( request: Request, session_id: str, ) -> EventSourceResponse: session = session_manager.get(session_id) if session is None: raise HTTPException(status_code=status.HTTP_403_FORBIDDEN) - event_source = status_stream(request, session) - return EventSourceResponse(event_source) + return EventSourceResponse(status_stream(request, session)) @router.get('/{download_id}', responses=depends_download_responses) diff --git a/core/ydcore/manager.py b/core/ydcore/manager.py index fcc8190f..360adcf9 100644 --- a/core/ydcore/manager.py +++ b/core/ydcore/manager.py @@ -15,7 +15,7 @@ def __init__( self, output_dir: str, status_hook: StatusHook | None = None, *, - num_threads: int | None = 2, + num_threads: int | None = None, ): self._status_hook = status_hook self._downloads: dict[str, DownloadConfig] = {}