This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients asvetlov, giampaolo.rodola, vstinner, yselivanov
Date 2019-01-08.01:08:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1546909720.17.0.329043242319.issue32710@roundup.psfhosted.org>
In-reply-to
Content
Update:

* test.test_asyncio.test_sendfile.ProactorEventLoopTests.test_sendfile_close_peer_in_the_middle_of_receiving leaks 1 reference per run: this bug is caused by bpo-35682 and fixed by PR 11462
* test.test_asyncio.test_sendfile.ProactorEventLoopTests.test_sendfile_fallback_close_peer_in_the_middle_of_receiving leaks 1 reference per run: I don't understand why.

I spent a lot of time to investigate test_sendfile_fallback_close_peer_in_the_middle_of_receiving() leak and I don't understand the issue. The main loop is BaseEventLoop._sendfile_fallback(). For the specific case of this test, the loop can be simplified to:

        proto = _SendfileFallbackProtocol(transp)
        try:
            while True:
                data = b'x' * (1024 * 64)
                await proto.drain()
                transp.write(data)
        finally:
            await proto.restore()

The server closes the connection after it gets 1024 bytes. The client socket gets a ConnectionAbortedError exception in _ProactorBaseWritePipeTransport._loop_writing() which calls _fatal_error():

        except OSError as exc:
            self._fatal_error(exc, 'Fatal write error on pipe transport')

_fatal_error() calls _force_close() which sets _closing to True and calls protocol.connection_lost(). In the meanwhile, drain() raises ConnectionError because is_closing() is true:

    async def drain(self):
        if self._transport.is_closing():
            raise ConnectionError("Connection closed by peer")
        ...
History
Date User Action Args
2019-01-08 01:08:41vstinnersetrecipients: + vstinner, giampaolo.rodola, asvetlov, yselivanov
2019-01-08 01:08:40vstinnersetmessageid: <1546909720.17.0.329043242319.issue32710@roundup.psfhosted.org>
2019-01-08 01:08:40vstinnerlinkissue32710 messages
2019-01-08 01:08:40vstinnercreate