Skip to content

Commit 8a43d0b

Browse files
authored
chore: update TestServer for support uvicorn v0.36+ (#1566)
### Description The update is necessary because `uvicorn` changed the initialization of `asyncio` and no longer receives the set policies. This was the reason why the configuration using `SelectorEventLoop` for Windows was not applied.
1 parent af46a37 commit 8a43d0b

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ dev = [
117117
"types-colorama<1.0.0",
118118
"types-psutil<8.0.0",
119119
"types-python-dateutil<3.0.0",
120-
"uvicorn[standard]~=0.35.0", # https://github.com/apify/crawlee-python/issues/1441
120+
"uvicorn[standard]<1.0.0",
121121
]
122122

123123
[tool.hatch.build.targets.wheel]

tests/unit/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ def run(self, sockets: list[socket] | None = None) -> None:
470470
# Set the event loop policy in thread with server for Windows and Python 3.12+.
471471
# This is necessary because there are problems with closing connections when using `ProactorEventLoop`
472472
if sys.version_info >= (3, 12) and sys.platform == 'win32':
473-
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
473+
return asyncio.run(self.serve(sockets=sockets), loop_factory=asyncio.SelectorEventLoop)
474474
super().run(sockets=sockets)
475+
return None
475476

476477

477478
def serve_in_thread(server: TestServer) -> Iterator[TestServer]:

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)