Hello,

On Thu, 11 Jun 2015 12:39:09 +0100
Gustavo Carneiro <[email protected]> wrote:

[]

> > By the end, to state the obvious, I don't call to do something about
> > existing synchronous write() - just for adding missing async one,
> > and letting people decide what they want to use.
> >
> 
> Yes.  But the async version is just a shortcut, it just saves you from
> adding an addition "yield from self.drain()" line, that's all.

No, as pointed out in the original mail. It straightens up API, and
makes asynchronous framework really asynchronous. Then 2 examples of
implementations were provided: on one extreme, async_write() will keep
*not* calling drain(). This choice would certainly be selected by
CPython's asyncio. Other extreme is calling drain() after each write.
This is the choice of MicroPython's uasyncio, which values memory more
than performance which can be achieved by consolidating small writes'
data.

But those are just 2 extremes. A both performant and robust
implementation of async_write() would set aside 1MB (1GB, 1TB) of
physical memory and buffer to it (return immediately) as long as
possible, and block and flush it otherwise. And it would do that
globally for all connections in asyncio loop instance, because it works
on that level. So there would never be drastic drop in response
performance, unlike a case when 1MB is reserved per connection, then
gazillion of connections arrive, and it all starts to swap/OOM.

> Actually, thinking about this problem some more, I wonder if we could
> do better?
> 
> I know we have WriteProtocol.set_write_buffer_limits(), which is

But I mentioned that in my original email too! Let me repeat that
argumentation again. Not "us" have it, "them" have it. Them being
Twisted, etc. Then nice guy Guido wanted to make asyncio a uniting
ground for all Python asynchronous frameworks, so he collected a piece
from each existing framework so nobody felt omitted. Very worthy and
honorable aim, I would probably do it like that if I was a BDFL.

But thanks god I am not, and have my independent opinion. I already
expressed it on python-dev and let me do it again: It might have been
better to leave Twisted and friends where they are, and take a fresh
start with asyncio.

But again, I don't call to remove all that Twisted, etc. stuff. All I
ask is: please, let there be asyncio implementations based on: 1)
coroutines; 2) nothing else. There's such implementation -
MicroPython's uasyncio. The only remaining stumbling block is
asynchronous write method. Please kindly let us be compatible with
asyncio, by adding to asyncio an async_write(). You don't have to use it
if you don't want (but trust me, people will like it and will use it).

[]


-- 
Best regards,
 Paul                          mailto:[email protected]

Reply via email to