(method)
Check if we can use the selector depending upon the
    operating system.
Check if we can use the selector depending upon the
    operating system.
Check if we can use the selector depending upon the operating system .
def _can_use(method):
    """Check if we can use the selector depending upon the
    operating system. """
    # Implementation based upon https://github.com/sethmlarson/selectors2/blob/master/selectors2.py
    selector = getattr(select, method, None)
    if selector is None:
        # select module does not implement method
        return False
    # check if the OS and Kernel actually support the method. Call may fail with
    # OSError: [Errno 38] Function not implemented
    try:
        selector_obj = selector()
        if method == 'poll':
            # check that poll actually works
            selector_obj.poll(0)
        else:
            # close epoll, kqueue, and devpoll fd
            selector_obj.close()
        return True
    except OSError:
        return False
def _can_use ( method ) : # Implementation based upon https://github.com/sethmlarson/selectors2/blob/master/selectors2.py selector = getattr ( select , method , None ) if selector is None : # select module does not implement method return False # check if the OS and Kernel actually support the method. Call may fail with # OSError: [Errno 38] Function not implemented try : selector_obj = selector ( ) if method == 'poll' : # check that poll actually works selector_obj . poll ( 0 ) else : # close epoll, kqueue, and devpoll fd selector_obj . close ( ) return True except OSError : return False