From 5ddd969a8ee7414469d34344c47e3c7659fff49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=90=9FJary=C3=A1n=F0=9F=8D=8B?= Date: Wed, 20 May 2026 22:54:27 +0800 Subject: [PATCH 1/2] Update main.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复Asyncio Windows兼容性 --- api/main.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/api/main.py b/api/main.py index 23e90f26b..705136c19 100644 --- a/api/main.py +++ b/api/main.py @@ -85,17 +85,29 @@ async def check_environment(): """Check if MediaCrawler environment is configured correctly""" try: # Run uv run main.py --help command to check environment - process = await asyncio.create_subprocess_exec( - "uv", "run", "main.py", "--help", - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd="." # Project root directory - ) - stdout, stderr = await asyncio.wait_for( - process.communicate(), - timeout=30.0 # 30 seconds timeout - ) - + if sys.platform == "win32": + loop = asyncio.get_running_loop() + process = await loop.run_in_executor( + None, + lambda: subprocess.run( + ["uv", "run", "main.py", "--help"], + capture_output=True, + timeout=30.0, + cwd="." + ) + ) + stdout, stderr = process.stdout, process.stderr # bytes + else: + process = await asyncio.create_subprocess_exec( + "uv", "run", "main.py", "--help", + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd="." # Project root directory + ) + stdout, stderr = await asyncio.wait_for( + process.communicate(), + timeout=30.0 # 30 seconds timeout + ) if process.returncode == 0: return { "success": True, @@ -125,7 +137,7 @@ async def check_environment(): return { "success": False, "message": "Environment check error", - "error": str(e) + "error": f"{type(e).__name__}: {str(e) or 'Unknown'}" } From 5ad5a93e00e075424d6cb842a2dde9e3ee96abd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=90=9FJary=C3=A1n=F0=9F=8D=8B?= Date: Thu, 21 May 2026 15:37:46 +0800 Subject: [PATCH 2/2] Update main.py sys --- api/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/main.py b/api/main.py index 705136c19..82f166493 100644 --- a/api/main.py +++ b/api/main.py @@ -23,6 +23,7 @@ """ import asyncio import os +import sys import subprocess import uvicorn from fastapi import FastAPI