Raise RuntimeError when transport's FD is used with add_reader etc by 1st1 · Pull Request #420 · python/asyncio (original) (raw)

This PR fixes #372.

The idea is that low-level socket APIs should refuse to work with FDs that belong to some Transport.

This PR adds private implementations for add_writer, add_reader, remove_writer, and remove_reader. Transports only call private implementation.

Public implementations of those methods do an extra check on the FD, raising a RuntimeError when the FD belongs to some Transport. loop.sock_sendall, loop.sock_connect, loop.sock_accept and loop.sock_recv only call public methods.

FWIW uvloop has a lot of functional network unittests, all of them pass on asyncio with this patch.