[issue32251] Add asyncio.BufferedProtocol

Yury Selivanov report at bugs.python.org
Mon Dec 11 11:46:57 EST 2017


Yury Selivanov <yselivanov at gmail.com> added the comment:

> See https://eklitzke.org/goroutines-nonblocking-io-and-memory-usage for an interesting discussion of the drawbacks of some buffer handling idioms.

Thanks for the link!

It does make sense to use a pool of buffers for the proposed BufferedProtocol when you need to keep thousands of long-open connections.  The current design makes that easy: when BufferedProtocol.get_buffer() is called you either take a buffer from the pool or allocate a temporary new one.

For use-cases like DB connections (asyncpg) a permanently allocated buffer per protocol instance is a good solution too, as usually there's a fairly limited number of open DB connections.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32251>
_______________________________________


More information about the Python-bugs-list mailing list