mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -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._iterator = iterator
|
||||||
self._paused = False
|
self._paused = False
|
||||||
|
|
||||||
# Register the producer and start producing data.
|
try:
|
||||||
self._request.registerProducer(self, True)
|
self._request.registerProducer(self, True)
|
||||||
self.resumeProducing()
|
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:
|
def _send_data(self, data: List[bytes]) -> None:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user