asyncio grpc & KeyboardInterrupt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grpc/examples/python/helloworld$ python async_greeter_server.py | |
DEBUG:asyncio:Using selector: EpollSelector | |
DEBUG:grpc._cython.cygrpc:Using AsyncIOEngine.POLLER as I/O engine | |
INFO:root:Starting server on [::]:50051 | |
^CDEBUG:grpc._cython.cygrpc:__dealloc__ called on running server <grpc._cython.cygrpc.AioServer object at 0x7f49685adc10> with status 4 | |
Traceback (most recent call last): | |
File "async_greeter_server.py", line 50, in <module> | |
asyncio.run(serve()) | |
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run | |
return loop.run_until_complete(main) | |
File "/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete | |
self.run_forever() | |
File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever | |
self._run_once() | |
File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once | |
event_list = self._selector.select(timeout) | |
File "/usr/lib/python3.8/selectors.py", line 468, in select | |
fd_event_list = self._selector.poll(timeout, max_ev) | |
KeyboardInterrupt | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
logging.basicConfig(level=logging.DEBUG) | |
loop = asyncio.get_event_loop() | |
server = grpc.aio.server() | |
try: | |
loop.run_until_complete(serve(server)) | |
except KeyboardInterrupt: | |
print('User quit.') | |
loop.run_until_complete(server.stop(0)) | |
finally: | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment