Yury Selivanov added the comment:

Another example: some asyncio (run with uvloop) code:
        conn, _ = lsock.accept()
        f = loop.create_task(
                proto_factory, conn))
        # More code

Suppose the above snippet of code is some real-world program.

Now, in Python 3.5 everything works as expected.  In Python 3.6, "conn.close()" 
will raise an exception.

Why: uvloop passes the FD of "conn" to libuv, which does its thing and closes 
the connection when it should be closed.


> 1. Your code should call sock0.detach() rather than fileno(), so that sock0 
> no longer “owns” the file descriptor, or

I can't modify "connect_accepted_socket" to call "detach" on "conn", as it 
would make "conn" unusable right after the call.  This option can't be 
implemented, as it would break the backwards compatibility.

> 2. libuv should not close file descriptors that it doesn’t own.

This is not just about uvloop/libuv.  It's about any Python program out there 
that will break in 3.6.  A lot of code extracts the FD out of socket objects 
and does something with it.  We can't just make socket.close() to raise in 3.6 
-- that's not how backwards compatibility promise works.

Guido, what do you think about this issue?


Python tracker <rep...@bugs.python.org>
Python-bugs-list mailing list

Reply via email to