MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _can_use

Function _can_use

tools/python-3.11.9-amd64/Lib/selectors.py:588–608  ·  view source on GitHub ↗

Check if we can use the selector depending upon the operating system.

(method)

Source from the content-addressed store, hash-verified

586
587
588def _can_use(method):
589 """Check if we can use the selector depending upon the
590 operating system. """
591 # Implementation based upon https://github.com/sethmlarson/selectors2/blob/master/selectors2.py
592 selector = getattr(select, method, None)
593 if selector is None:
594 # select module does not implement method
595 return False
596 # check if the OS and Kernel actually support the method. Call may fail with
597 # OSError: [Errno 38] Function not implemented
598 try:
599 selector_obj = selector()
600 if method == 'poll':
601 # check that poll actually works
602 selector_obj.poll(0)
603 else:
604 # close epoll, kqueue, and devpoll fd
605 selector_obj.close()
606 return True
607 except OSError:
608 return False
609
610
611# Choose the best implementation, roughly:

Callers 1

selectors.pyFile · 0.85

Calls 2

pollMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected