Skip to content

Commit

Permalink
Merge pull request #62 from bobh66/loop
Browse files Browse the repository at this point in the history
Fix different loop errors on python 3.12
  • Loading branch information
negz committed Jun 26, 2024
2 parents 8261272 + c214b4b commit d1c067e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion crossplane/function/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -104,7 +107,6 @@ async def start():
await server.start()
await server.wait_for_termination()

loop = asyncio.get_event_loop()
try:
loop.run_until_complete(start())
finally:
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages = ["crossplane"]
[tool.ruff]
target-version = "py311"
exclude = ["crossplane/function/proto/*"]
select = [
lint.select = [
"A",
"ARG",
"ASYNC",
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit d1c067e

Please sign in to comment.