Fix different loop errors in 3.12

Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
This commit is contained in:
Bob Haddleton 2024-06-25 18:35:10 -05:00
parent 00beeb1ba7
commit a24b927baf
1 changed files with 3 additions and 1 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: