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.
This commit is contained in:
2026-05-24 19:14:31 +00:00
parent 8586bd26e1
commit 780f223b82
+9 -5
View File
@@ -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,