bpo-34666: Implement stream.awrite() and stream.aclose() (GH-9274)
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index e7fb22e..0afc66a 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -348,7 +348,7 @@
# a reader can be garbage collected
# after connection closing
self._protocol._untrack_reader()
- return self._transport.close()
+ self._transport.close()
def is_closing(self):
return self._transport.is_closing()
@@ -381,6 +381,14 @@
await sleep(0, loop=self._loop)
await self._protocol._drain_helper()
+ async def aclose(self):
+ self.close()
+ await self.wait_closed()
+
+ async def awrite(self, data):
+ self.write(data)
+ await self.drain()
+
class StreamReader: