MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / drain_writers

Method drain_writers

mitmproxy/proxy/server.py:330–342  ·  view source on GitHub ↗

Drain all writers to create some backpressure. We won't continue reading until there's space available in our write buffers, so if we cannot write fast enough our own read buffers run full and the TCP recv stream is throttled.

(self)

Source from the content-addressed store, hash-verified

328 raise cancelled
329
330 async def drain_writers(self):
331 """
332 Drain all writers to create some backpressure. We won't continue reading until there's space available in our
333 write buffers, so if we cannot write fast enough our own read buffers run full and the TCP recv stream is throttled.
334 """
335 async with self._drain_lock:
336 for transport in list(self.transports.values()):
337 if transport.writer is not None:
338 try:
339 await transport.writer.drain()
340 except OSError as e:
341 if transport.handler is not None:
342 transport.handler.cancel(f"Error sending data: {e}")
343
344 async def on_timeout(self) -> None:
345 try:

Callers 1

handle_connectionMethod · 0.95

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected