From a24b927bafc0cd1e07022df528519923357460e0 Mon Sep 17 00:00:00 2001 From: Bob Haddleton Date: Tue, 25 Jun 2024 18:35:10 -0500 Subject: [PATCH 1/2] Fix different loop errors in 3.12 Signed-off-by: Bob Haddleton --- crossplane/function/runtime.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crossplane/function/runtime.py b/crossplane/function/runtime.py index fa6023b..6eb7539 100644 --- a/crossplane/function/runtime.py +++ b/crossplane/function/runtime.py @@ -82,6 +82,9 @@ def serve( If insecure is true requests will be served insecurely, even if credentials are supplied. """ + # Define the loop before the server so everything uses the same loop. + loop = asyncio.get_event_loop() + server = grpc.aio.server() grpcv1beta1.add_FunctionRunnerServiceServicer_to_server(function, server) @@ -104,7 +107,6 @@ def serve( await server.start() await server.wait_for_termination() - loop = asyncio.get_event_loop() try: loop.run_until_complete(start()) finally: From c214b4b1ba16d55ce94dba2534d75bb07bf8663c Mon Sep 17 00:00:00 2001 From: Bob Haddleton Date: Tue, 25 Jun 2024 18:37:39 -0500 Subject: [PATCH 2/2] Fix lint configuration warnings Signed-off-by: Bob Haddleton --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9e9f46d..288f7a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ packages = ["crossplane"] [tool.ruff] target-version = "py311" exclude = ["crossplane/function/proto/*"] -select = [ +lint.select = [ "A", "ARG", "ASYNC", @@ -103,12 +103,12 @@ select = [ "W", "YTT", ] -ignore = ["ISC001"] # Ruff warns this is incompatible with ruff format. +lint.ignore = ["ISC001"] # Ruff warns this is incompatible with ruff format. [tool.ruff.lint.per-file-ignores] "tests/*" = ["D"] # Don't require docstrings for tests. -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ["crossplane"] [tool.ruff.lint.pydocstyle]