Propagate manual close codes to socket subclass

aiohttp seems to not set it during its state machine flow
This commit is contained in:
Rapptz
2020-08-05 04:27:11 -04:00
parent a9824ffabf
commit 3a1a215f8b
2 changed files with 13 additions and 7 deletions

View File

@ -159,10 +159,10 @@ class ConnectionClosed(ClientException):
shard_id: Optional[:class:`int`]
The shard ID that got closed if applicable.
"""
def __init__(self, socket, *, shard_id):
def __init__(self, socket, *, shard_id, code=None):
# This exception is just the same exception except
# reconfigured to subclass ClientException for users
self.code = socket.close_code
self.code = code or socket.close_code
# aiohttp doesn't seem to consistently provide close reason
self.reason = ''
self.shard_id = shard_id