WIP: bpo-33694, asyncio: fix proactor transport pause/resume by vstinner · Pull Request #7479 · python/cpython (original) (raw)
I actually like the fix and I think it's a very nice way of solving the race between different protocols types after set_protocol is called.
I don't think that my code for data_received() <=> buffer_updated() protocol transitions is safe. My code keeps a reference to the buffer of the previous protocol (after set_protocol()) and even write into the old buffer, again, even after set_protocol(). That's weird and counter-intuitive, and may lead to crazy bugs.
All the complexity of my PR comes from the fact that proactor has two implementation to read: recv() and recv_into(). If we reimplemented recv_into() on top of recv(), the code becomes again managable, simple and straightforward. Well, it's not my idea, it's @1st1 idea :-)
Since we are close to 3.7.0 final, I would prefer to first to loose data randomly, and then reconsider implementing recv_into() optimization :-)