Merge pull request #62 from bobh66/loop

Fix different loop errors on python 3.12
This commit is contained in:
Nic Cope 2024-06-26 13:38:13 -07:00 committed by GitHub
commit d1c067e388
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -82,6 +82,9 @@ def serve(
If insecure is true requests will be served insecurely, even if credentials If insecure is true requests will be served insecurely, even if credentials
are supplied. are supplied.
""" """
# Define the loop before the server so everything uses the same loop.
loop = asyncio.get_event_loop()
server = grpc.aio.server() server = grpc.aio.server()
grpcv1beta1.add_FunctionRunnerServiceServicer_to_server(function, server) grpcv1beta1.add_FunctionRunnerServiceServicer_to_server(function, server)
@ -104,7 +107,6 @@ def serve(
await server.start() await server.start()
await server.wait_for_termination() await server.wait_for_termination()
loop = asyncio.get_event_loop()
try: try:
loop.run_until_complete(start()) loop.run_until_complete(start())
finally: finally:

View File

@ -73,7 +73,7 @@ packages = ["crossplane"]
[tool.ruff] [tool.ruff]
target-version = "py311" target-version = "py311"
exclude = ["crossplane/function/proto/*"] exclude = ["crossplane/function/proto/*"]
select = [ lint.select = [
"A", "A",
"ARG", "ARG",
"ASYNC", "ASYNC",
@ -103,12 +103,12 @@ select = [
"W", "W",
"YTT", "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] [tool.ruff.lint.per-file-ignores]
"tests/*" = ["D"] # Don't require docstrings for tests. "tests/*" = ["D"] # Don't require docstrings for tests.
[tool.ruff.isort] [tool.ruff.lint.isort]
known-first-party = ["crossplane"] known-first-party = ["crossplane"]
[tool.ruff.lint.pydocstyle] [tool.ruff.lint.pydocstyle]