def test_releaseIgnoresEBADF(self):
        """
        L{_ExhaustsFileDescriptors.release} continues to close opened
        file descriptors even when closing one fails with C{EBADF}.
        """
        fileDescriptors = []

        def recordFileDescriptors():
            fd = os.dup(0)
            fileDescriptors.append(fd)
            return fd

        exhauster = _ExhaustsFileDescriptors(recordFileDescriptors)
        self.addCleanup(exhauster.release)

        exhauster.exhaust()
        self.assertGreater(exhauster.count(), 0)

        os.close(fileDescriptors[0])

        exhauster.release()
        self.assertEqual(exhauster.count(), 0)

        L{_ExhaustsFileDescriptors.release} continues to close opened
        file descriptors even when closing one fails with C{EBADF}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_tcp.py