grpclib icon indicating copy to clipboard operation
grpclib copied to clipboard

Server doesn't stay open in Python 3.12

Open kochie opened this issue 2 years ago • 3 comments

Due to changes in what I think is the asyncio library the example servers no longer stay running in Python 3.12. The server will successfully start but will immediately exit.

Changes can be found in the What's New for Python 3.12

The issue seems to be with server.wait_closed() as

server = Server([Health()])
with graceful_exit([server]):
    await server.start(port=port, ssl=context)
    print(f"Serving on {''}:{port}", flush=True)
    # await server.wait_closed()
    await asyncio.sleep(10)

print("Closing")

will wait for 10 seconds but

server = Server([Health()])
with graceful_exit([server]):
    await server.start(port=port, ssl=context)
    print(f"Serving on {''}:{port}", flush=True)
    await server.wait_closed()
    # await asyncio.sleep(10)

print("Closing")

Immediately closes

kochie avatar Oct 16 '23 02:10 kochie

Yes, Python 3.12 changed how asyncio:Server.wait_closed work, will release the fix soon

vmagamedov avatar Oct 19 '23 19:10 vmagamedov

Issued 0.4.7rc1 release candidate with Python 3.12 support added, please try it and tell if it solves your issue.

vmagamedov avatar Oct 28 '23 18:10 vmagamedov

I'm not the original poster but I was facing the same issue -- the release candidate has seemed to fix it. Thanks for the quick turnaround!

njooma avatar Oct 31 '23 18:10 njooma