|
|
|
Created:
11 years, 10 months ago by haypo_gmail Modified:
11 years, 10 months ago Reviewers:
GvR Visibility:
Public. |
drain(�) is a coroutine
Patch Set 1 #
Total messages: 3
|
GvR
Let me think about this. There was something clever about this. I think it was ...
|
11 years, 10 months ago (2014年02月26日 00:01:08 UTC) #1 | ||||||||||||||
Let me think about this. There was something clever about this. I think it was allowing code that would keep writing (without ever yielding) until the buffer is full, e.g. while True: while True: s.write(b'x') w = s.drain() if w: break yield from w But this may be excessively clever.
On 2014年02月26日 00:01:08, GvR wrote: > Let me think about this. There was something clever about this. I think it was > allowing code that would keep writing (without ever yielding) until the buffer > is full, e.g. > > while True: > while True: > s.write(b'x') > w = s.drain() > if w: > break > yield from w > > But this may be excessively clever. It makes the common case look weird. If you consider this use case important enough, why not adding a method to check if the buffer is full which would simply return a boolean? I never had to check if a write buffer is full or not.
What's weird about the common case? You can just write s.write(b'x') yield from s.drain() There's normally no need to check for drain()'s return value.