mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Fix exception responding to request that has been closed (#10932)
Introduced in #10905
This commit is contained in:
parent
2b9d174791
commit
37bb93d181
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 New Issue
Block a user