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

Method select

Lib/selectors.py:385–409  ·  view source on GitHub ↗
(self, timeout=None)

Source from the content-addressed store, hash-verified

383 return key
384
385 def select(self, timeout=None):
386 # This is shared between poll() and epoll().
387 # epoll() has a different signature and handling of timeout parameter.
388 if timeout is None:
389 timeout = None
390 elif timeout <= 0:
391 timeout = 0
392 else:
393 # poll() has a resolution of 1 millisecond, round away from
394 # zero to wait *at least* timeout seconds.
395 timeout = math.ceil(timeout * 1e3)
396 ready = []
397 try:
398 fd_event_list = self._selector.poll(timeout)
399 except InterruptedError:
400 return ready
401
402 fd_to_key_get = self._fd_to_key.get
403 for fd, event in fd_event_list:
404 key = fd_to_key_get(fd)
405 if key:
406 events = ((event & ~self._EVENT_READ and EVENT_WRITE)
407 | (event & ~self._EVENT_WRITE and EVENT_READ))
408 ready.append((key, events & key.events))
409 return ready
410
411
412if hasattr(select, 'poll'):

Callers

nothing calls this directly

Calls 2

pollMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected