File tree Expand file tree Collapse file tree 5 files changed +11
-26
lines changed Expand file tree Collapse file tree 5 files changed +11
-26
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,9 @@ exclude_lines = [
161161 " uvicorn/supervisors/multiprocess.py" ,
162162 " tests/supervisors/test_multiprocess.py" ,
163163]
164- "sys_platform != 'win32'" = [" uvicorn/loops/asyncio.py" ]
164+ "sys_platform != 'win32'" = [
165+ " uvicorn/loops/winloop.py" ,
166+ ]
165167
166168[tool .coverage .coverage_conditional_plugin .rules ]
167169py-win32 = " sys_platform == 'win32'"
Original file line number Diff line number Diff line change 1111from uvicorn .protocols .websockets .auto import AutoWebSocketsProtocol
1212from uvicorn .server import ServerState
1313
14- # Determine expected loop implementation based on platform
1514try :
16- if sys .platform == "win32" :
17- # On Windows, check for winloop first, then asyncio
15+ if sys .platform == "win32" : # pragma: py-not-win32
1816 importlib .import_module ("winloop" )
1917 expected_loop = "winloop"
20- else :
21- # On Unix, check for uvloop first, then asyncio
18+ else : # pragma: py-win32
2219 importlib .import_module ("uvloop" )
23- expected_loop = "uvloop" # pragma: py-win32
24- except ImportError : # pragma: py-not-win32
20+ expected_loop = "uvloop"
21+ except ImportError : # pragma: no cover
2522 expected_loop = "asyncio"
2623
2724try :
Original file line number Diff line number Diff line change @@ -593,17 +593,3 @@ def test_setup_event_loop_is_removed(caplog: pytest.LogCaptureFixture) -> None:
593593 AttributeError , match = "The `setup_event_loop` method was replaced by `get_loop_factory` in uvicorn 0.36.0."
594594 ):
595595 config .setup_event_loop ()
596-
597-
598- @pytest .mark .skipif (sys .platform != "win32" , reason = "winloop is for Windows only" )
599- def test_winloop_loop_factory () -> None :
600- """Test that winloop can be explicitly configured on Windows."""
601- pytest .importorskip ("winloop" )
602- config = Config (app = asgi_app , loop = "winloop" )
603- config .load ()
604- loop_factory = config .get_loop_factory ()
605- assert loop_factory is not None
606- event_loop = loop_factory ()
607- with closing (event_loop ):
608- assert event_loop is not None
609- assert type (event_loop ).__module__ .startswith ("winloop" )
Original file line number Diff line number Diff line change 66
77
88def asyncio_loop_factory (use_subprocess : bool = False ) -> Callable [[], asyncio .AbstractEventLoop ]:
9- if sys .platform == "win32" and not use_subprocess :
9+ if sys .platform == "win32" and not use_subprocess : # pragma: py-not-win32
1010 return asyncio .ProactorEventLoop
11- return asyncio .SelectorEventLoop
11+ return asyncio .SelectorEventLoop # pragma: py-win32
Original file line number Diff line number Diff line change 77
88def auto_loop_factory (use_subprocess : bool = False ) -> Callable [[], asyncio .AbstractEventLoop ]:
99 try :
10- if sys .platform == "win32" :
10+ if sys .platform == "win32" : # pragma: py-not-win32
1111 from uvicorn .loops .winloop import winloop_loop_factory as loop_factory
12- else :
12+ else : # pragma: py-win32
1313 from uvicorn .loops .uvloop import uvloop_loop_factory as loop_factory
1414 except ImportError : # pragma: no cover
1515 from uvicorn .loops .asyncio import asyncio_loop_factory as loop_factory
You can’t perform that action at this time.
0 commit comments