'Pick a method which gives correct results for C{_listOpenFDs} in this
runtime environment.
This involves a lot of very platform-specific checks, some of which may
be relatively expensive.  Therefore the returned method should be saved
and re-used, rather than always calling this method to determine what it
is.
See the implementation for the details of how a method is selected.'

def _getImplementation(self):

    for impl in self._implementations:
        try:
            before = impl()
        except:
            continue
        with self.openfile('/dev/null', 'r'):
            after = impl()
        if (before != after):
            return impl
    return impl
