'Fallback implementation where either the resource module can inform us
about the upper bound of how many FDs to expect, or where we just guess
a constant maximum if there is no resource module.
All possible file descriptors from 0 to that upper bound are returned
with no attempt to exclude invalid file descriptor values.'

def _fallbackFDImplementation(self):

    try:
        import resource
    except ImportError:
        maxfds = 1024
    else:
        maxfds = min(1024, resource.getrlimit(resource.RLIMIT_NOFILE)[1])
    return range(maxfds)
