MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / drain

Method drain

tools/python-3.11.9-amd64/Lib/asyncio/streams.py:369–392  ·  view source on GitHub ↗

Flush the write buffer. The intended use is to write w.write(data) await w.drain()

(self)

Source from the content-addressed store, hash-verified

367 return self._transport.get_extra_info(name, default)
368
369 async def drain(self):
370 """Flush the write buffer.
371
372 The intended use is to write
373
374 w.write(data)
375 await w.drain()
376 """
377 if self._reader is not None:
378 exc = self._reader.exception()
379 if exc is not None:
380 raise exc
381 if self._transport.is_closing():
382 # Wait for protocol.connection_lost() call
383 # Raise connection closing error if any,
384 # ConnectionResetError otherwise
385 # Yield to the event loop so connection_lost() may be
386 # called. Without this, _drain_helper() would return
387 # immediately, and code that calls
388 # write(...); await drain()
389 # in a loop would never call connection_lost(), so it
390 # would not see an error when the socket is closed.
391 await sleep(0)
392 await self._protocol._drain_helper()
393
394 async def start_tls(self, sslcontext, *,
395 server_hostname=None,

Callers 2

start_tlsMethod · 0.95
_feed_stdinMethod · 0.45

Calls 4

_drain_helperMethod · 0.80
sleepFunction · 0.70
exceptionMethod · 0.45
is_closingMethod · 0.45

Tested by

no test coverage detected