vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
922 stars 93 forks source link

AttributeError: 'SSLContext' object has no attribute '_set_npn_protocols' in Python 3.10 #150

Closed fundthmcalculus closed 2 years ago

fundthmcalculus commented 2 years ago

When trying to create a secure channel in Python 3.10, there is a failure:

    channel = Channel(host=config.endpoint, port=config.port, ssl=config.use_tls)
  File "C:\work\sdk\python\venv\lib\site-packages\grpclib\client.py", line 659, in __init__
    ssl = self._get_default_ssl_context()
  File "C:\work\sdk\python\venv\lib\site-packages\grpclib\client.py", line 756, in _get_default_ssl_context
    ctx.set_npn_protocols(['h2'])
  File "C:\Program Files\Python310\lib\ssl.py", line 546, in set_npn_protocols
    self._set_npn_protocols(protos)
AttributeError: 'SSLContext' object has no attribute '_set_npn_protocols'

We should be able to easily fix this with an additional catch clause

vmagamedov commented 2 years ago

Issued grpclib==0.4.3rc2