vmagamedov / grpclib

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

Fix double-close crash after abort, Python 3.11 #180

Closed xloem closed 7 months ago

xloem commented 1 year ago

This addresses a crash I’ve been encountering with ssl on python 3.11 when the connection aborts unexpectedly.

vmagamedov commented 1 year ago

asyncio transports allow calling transport.close() more than once: https://github.com/python/cpython/blob/c163d7f0b67a568e9b64eeb9c1cbbaa127818596/Lib/asyncio/sslproto.py#L110-L114

xloem commented 1 year ago

I vaguely recall, if you check the section you hilighted, a second call to close() resets a member variable to None, causing other member functions to crash, whereas a single call does not do this. edit: https://github.com/python/cpython/blob/c163d7f0b67a568e9b64eeb9c1cbbaa127818596/Lib/asyncio/sslproto.py#L113-L114

vmagamedov commented 7 months ago

Related to #185. Fix was implemented in other place.