Skip to content

Commit

Permalink
Two asyncio changes that fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Oct 12, 2023
1 parent 723b428 commit 84c73c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions asyncio/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions asyncio/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 84c73c6

Please sign in to comment.