MCPcopy Index your code
hub / github.com/python/cpython / drain

Method drain

Lib/asyncio/streams.py:361–384  ·  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

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

Callers 12

start_tlsMethod · 0.95
_feed_stdinMethod · 0.45
handle_clientMethod · 0.45
clientMethod · 0.45
server_handlerMethod · 0.45
innerMethod · 0.45
handle_clientMethod · 0.45
mainMethod · 0.45
runMethod · 0.45
write_stdinMethod · 0.45
handle_clientMethod · 0.45
writeMethod · 0.45

Calls 4

sleepFunction · 0.85
_drain_helperMethod · 0.80
exceptionMethod · 0.45
is_closingMethod · 0.45

Tested by 10

handle_clientMethod · 0.36
clientMethod · 0.36
server_handlerMethod · 0.36
innerMethod · 0.36
handle_clientMethod · 0.36
mainMethod · 0.36
runMethod · 0.36
write_stdinMethod · 0.36
handle_clientMethod · 0.36
writeMethod · 0.36