Fix mypy on latest Twisted release (#17036)

`ITransport.abortConnection` isn't a thing, but
`HTTPChannel.forceAbortClient` calls it, so lets just use that

Fixes https://github.com/element-hq/synapse/issues/16728
This commit is contained in:
Erik Johnston 2024-04-11 16:03:45 +01:00 committed by GitHub
parent db4e321219
commit 3a30846bd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 4 deletions

1
changelog.d/17036.misc Normal file
View File

@ -0,0 +1 @@
Fix mypy with latest Twisted release.

View File

@ -262,7 +262,8 @@ class _ProxyResponseBody(protocol.Protocol):
self._request.finish() self._request.finish()
else: else:
# Abort the underlying request since our remote request also failed. # Abort the underlying request since our remote request also failed.
self._request.transport.abortConnection() if self._request.channel:
self._request.channel.forceAbortClient()
class ProxySite(Site): class ProxySite(Site):

View File

@ -153,9 +153,9 @@ def return_json_error(
# Only respond with an error response if we haven't already started writing, # Only respond with an error response if we haven't already started writing,
# otherwise lets just kill the connection # otherwise lets just kill the connection
if request.startedWriting: if request.startedWriting:
if request.transport: if request.channel:
try: try:
request.transport.abortConnection() request.channel.forceAbortClient()
except Exception: except Exception:
# abortConnection throws if the connection is already closed # abortConnection throws if the connection is already closed
pass pass

View File

@ -150,7 +150,8 @@ class SynapseRequest(Request):
self.get_method(), self.get_method(),
self.get_redacted_uri(), self.get_redacted_uri(),
) )
self.transport.abortConnection() if self.channel:
self.channel.forceAbortClient()
return return
super().handleContentChunk(data) super().handleContentChunk(data)