-
Notifications
You must be signed in to change notification settings - Fork 11.1k
[python aio] AttributeError: module 'grpc' has no attribute 'aio' #24281
Copy link
Copy link
Closed
Labels
Description
What version of gRPC and what language are you using?
$ pip freeze
grpcio==1.32.0
six==1.15.0
What operating system (Linux, Windows,...) and version?
Fedora 32 Linux
What runtime / compiler are you using (e.g. python version or version of gcc)
Python 3.8.5 (default, Aug 12 2020, 00:00:00)
[GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]
What did you do?
create file server.py
#! /usr/bin/env python
import asyncio
import logging
from concurrent import futures
import grpc
logging.basicConfig(level=logging.DEBUG)
addr = '[::]:50051'
async def run():
server = grpc.aio.server(futures.ThreadPoolExecutor(max_workers=10))
server.add_insecure_port(addr)
logging.info(f"Listening on {addr}")
await server.start()
await server.wait_for_termination()
if __name__ == '__main__':
asyncio.run(run())
What did you expect to see?
the code execute and print out
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:grpc._cython.cygrpc:Using AsyncIOEngine.POLLER as I/O engine
INFO:root:Listening on [::]:50051
What did you see instead?
I get an import error.
$ python server.py
Traceback (most recent call last):
File "server.py", line 16, in <module>
asyncio.run(run())
File "/usr/lib64/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "server.py", line 9, in run
server = grpc.aio.server(futures.ThreadPoolExecutor(max_workers=10))
AttributeError: module 'grpc' has no attribute 'aio'
Reactions are currently unavailable