Hi,

The method loop.create_server() allows to use an existing socket, but will 
however perform a call to listen() on that socket. I am not sure why it's 
not up the user creating the socket to perform that call. In particular, on 
Linux (I don't know for others systems), it will change the backlog size to 
the value of the latest call to listen. It might happen that the user does 
not know the size of the backlog and does not want to change it - for 
instance when the socket is created with socket.fromfd(). Maybe it's enough 
if this behavior is documented, since there is a simple workaround 
(subclass socket.socket and make listen() a no-op).

I also have questions about StreamWriter and the flow control system.

I understood that I am expected to yield from writer.drain() after any call 
to writer.write(), so the flow control mechanism can make the calling task 
wait until the buffer gets downsized to the low-water limit. I don't 
understand why the writer.write[lines]() functions are not coroutines which 
actually yield from writer.drain(), nor why the "yield from writer.drain()" 
is not performed before the call to write().

On a related topic, is there a reason why StreamWriter does not have a 
flush() coroutine, or any other way to wait until the buffer is empty? The 
only workaround I've got for this is to temporarily force high and low 
water limits to 0 so writer.drain() will wait until the buffer is actually 
empty.

Thank you for your insights.

Cheers,
Martin

Reply via email to