From 780f223b82d495f8f95ac7468b45ba7337510d2d Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Sun, 24 May 2026 19:14:31 +0000 Subject: [PATCH] Fix uvicorn forcing SelectorEventLoop on Windows dev mode Uvicorn's asyncio_loop_factory returns SelectorEventLoop on Windows whenever reload=True (use_subprocess=True). SelectorEventLoop does not support asyncio subprocess APIs, causing NotImplementedError in the app. Fix: pass loop='none' so uvicorn respects the ProactorEventLoop policy we configure, instead of overriding it. Also suppress the Py3.14 DeprecationWarning on the policy class itself. --- mediahive/__main__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mediahive/__main__.py b/mediahive/__main__.py index 110e214..e7177a7 100644 --- a/mediahive/__main__.py +++ b/mediahive/__main__.py @@ -15,10 +15,14 @@ def _configure_windows_event_loop_policy() -> None: """Ensure Windows uses Proactor loop so asyncio subprocess APIs are available.""" if sys.platform != "win32": return - policy_cls = getattr(asyncio, "WindowsProactorEventLoopPolicy", None) - if policy_cls is None: - return - asyncio.set_event_loop_policy(policy_cls()) + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + policy_cls = getattr(asyncio, "WindowsProactorEventLoopPolicy", None) + if policy_cls is None: + return + asyncio.set_event_loop_policy(policy_cls()) def _derive_name(path: str) -> str: @@ -64,7 +68,7 @@ def main(): roots[name] = p.as_posix() os.environ["MEDIAHIVE_ROOTS"] = json.dumps(roots) - dev = {"reload": True, "reload_dirs": ["mediahive"]} + dev = {"reload": True, "reload_dirs": ["mediahive"], "loop": "none"} server.run( "mediahive.server:app", listen=args.listen,