Need to check if transport is closing to avoid getting stuck in sending loops after peer has disconnected.

This commit is contained in:
L. Kärkkäinen 2020-03-10 15:23:22 +02:00
parent 2adcc72e06
commit d2d6008eec

View File

@ -184,6 +184,8 @@ class HttpProtocol(asyncio.Protocol):
async def send(self, data): async def send(self, data):
"""Writes data with backpressure control.""" """Writes data with backpressure control."""
await self._can_write.wait() await self._can_write.wait()
if self.transport.is_closing():
raise CancelledError
self.transport.write(data) self.transport.write(data)
self._time = current_time() self._time = current_time()