mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-14 22:11:47 +01:00
Fix exception responding to request that has been closed (#10932)
Introduced in #10905
This commit is contained in:
parent
2b9d174791
commit
37bb93d181
2 changed files with 12 additions and 3 deletions
1
changelog.d/10932.feature
Normal file
1
changelog.d/10932.feature
Normal file
|
@ -0,0 +1 @@
|
|||
Speed up responding with large JSON objects to requests.
|
|
@ -561,9 +561,17 @@ class _ByteProducer:
|
|||
self._iterator = iterator
|
||||
self._paused = False
|
||||
|
||||
# Register the producer and start producing data.
|
||||
self._request.registerProducer(self, True)
|
||||
self.resumeProducing()
|
||||
try:
|
||||
self._request.registerProducer(self, True)
|
||||
except RuntimeError as e:
|
||||
logger.info("Connection disconnected before response was written: %r", e)
|
||||
|
||||
# We drop our references to data we'll not use.
|
||||
self._request = None
|
||||
self._iterator = iter(())
|
||||
else:
|
||||
# Start producing if `registerProducer` was successful
|
||||
self.resumeProducing()
|
||||
|
||||
def _send_data(self, data: List[bytes]) -> None:
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue