MCPcopy Index your code
hub / github.com/python/cpython / _can_use

Function _can_use

Lib/selectors.py:568–588  ·  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

566
567
568def _can_use(method):
569 """Check if we can use the selector depending upon the
570 operating system. """
571 # Implementation based upon https://github.com/sethmlarson/selectors2/blob/master/selectors2.py
572 selector = getattr(select, method, None)
573 if selector is None:
574 # select module does not implement method
575 return False
576 # check if the OS and Kernel actually support the method. Call may fail with
577 # OSError: [Errno 38] Function not implemented
578 try:
579 selector_obj = selector()
580 if method == 'poll':
581 # check that poll actually works
582 selector_obj.poll(0)
583 else:
584 # close epoll, kqueue, and devpoll fd
585 selector_obj.close()
586 return True
587 except OSError:
588 return False
589
590
591# 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…