diff --git a/asyncio/funcs.py b/asyncio/funcs.py index baf804d..b1bb24a 100644 --- a/asyncio/funcs.py +++ b/asyncio/funcs.py @@ -98,6 +98,9 @@ async def gather(*aws, return_exceptions=False): Returns a list of return values of all *aws* """ + if not aws: + return [] + def done(t, er): # Sub-task "t" has finished, with exception "er". nonlocal state diff --git a/asyncio/stream.py b/asyncio/stream.py index 4a9d6bf..44a8cc5 100644 --- a/asyncio/stream.py +++ b/asyncio/stream.py @@ -113,6 +113,13 @@ def write(self, buf): `Stream.drain` is called. It is recommended to call `Stream.drain` immediately after calling this function. """ + if not self.out_buf: + # Try to write immediately to the underlying stream. + ret = self.s.write(buf) + if ret == len(buf): + return + if ret is not None: + buf = buf[ret:] self.out_buf += buf